From: James Hughes Date: 2009-04-30T08:27:39+09:00 Subject: problems with 'require' in embedded ruby I'm tinkering with my first C++ app with an embedded Ruby interpreter. I'm having trouble with pretty much any usage of 'require' that involves a file not in the same folder as the executable. If I use rb_require, it blows up. If I do it in the script, it blows up. I've checked the $LOAD_PATH variable on both the C++ side and the script side, and it's reporting the values I expect. The modules I'm requiring are definitely in the $LOAD_PATH directories. I'm getting a memory access error. It's mostly trying to access address 0x0. Anyone have any inkling of what's going on here? My version of Ruby wasn't compiled with symbols, so I can't see what's going on once the code enters the interpreter (I'm not much for wading through disassembly). ==== c++ ==== int main(int argc, char *argv[]) { VALUE result; ruby_sysinit(&argc, &argv); RUBY_INIT_STACK; ruby_init(); ruby_init_loadpath(); #ifdef _DEBUG rb_eval_string("puts $LOAD_PATH"); #endif rb_require("rules"); return ruby_cleanup(0); } ==== rules.rb ==== puts $LOAD_PATH require 'pp' class Rules def self.apply(arr_face) puts "array: #{arr_face.size}" if arr_face.kind_of?(Array) puts arr_face.pretty_inspect return (arr_face.size > 0) ? 1 : 0 end end -- Posted via http://www.ruby-forum.com/.