Ruby 1.9 evaled from C doesn't load libraries properly

A

Alex Maccaw

Ok, so I'm using C++ in a project called Titanium and trying to evaluate
Ruby (1.9).

The code looks something like this:

ruby_init();
ruby_init_loadpath();
rb_set_safe_level(0);
ruby_script("ruby");
rb_eval_string_protect(code, &error);


So, this can parse Ruby fine, the only issue is when I require the mutex
lib (needed by Rubygems).

The error I get is: undefined method `synchronize' for #<Mutex:0x1f8cf4>

It looks like the mutex class (which is written in C) isn't getting
loaded properly. Anybody got any ideas as to why?
 
E

Eric Hodel

Ok, so I'm using C++ in a project called Titanium and trying to
evaluate
Ruby (1.9).

The code looks something like this:

ruby_init();
ruby_init_loadpath();
rb_set_safe_level(0);
ruby_script("ruby");
rb_eval_string_protect(code, &error);


So, this can parse Ruby fine, the only issue is when I require the
mutex
lib (needed by Rubygems).

RubyGems requires thread by itself, why are you doing it? Why not
require 'rubygems'?
 
A

Alex Maccaw

Eric said:
RubyGems requires thread by itself, why are you doing it? Why not
require 'rubygems'?

When I require 'rubygems' I get that error - I traced it back to the
Mutex lib in the thread lib.
In other words, rubygems won't work.

Also, peculiarly, if I stub out the schedule method on Mutex like this:

require 'thread'
class ::Mutex
def synchronize
yield
end
end

Then rubygems seems to load fine, but any other gems, such as
activesupport won't load through rubygems.

It's really odd...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top