Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby 1.9 evaled from C doesn't load libraries properly

Reply
Thread Tools

Ruby 1.9 evaled from C doesn't load libraries properly

 
 
Alex Maccaw
Guest
Posts: n/a
 
      08-10-2009
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?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Alex Maccaw
Guest
Posts: n/a
 
      08-12-2009
I should add that other libraries written in C, like StringIO, work
fine.

Alex Maccaw wrote:
> 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?


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Eric Hodel
Guest
Posts: n/a
 
      08-12-2009
On Aug 10, 2009, at 14:52, Alex Maccaw wrote:
> 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'?

> 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?
> --
> Posted via http://www.ruby-forum.com/.
>



 
Reply With Quote
 
Alex Maccaw
Guest
Posts: n/a
 
      08-12-2009
Eric Hodel wrote:
> On Aug 10, 2009, at 14:52, Alex Maccaw wrote:
>> 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'?


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...
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
standard libraries don't behave like standard 'libraries' Sriram Srinivasan Python 13 11-12-2009 06:05 PM
Using mandatory libraries (custom class loading vs. expanding libraries) Karsten Wutzke Java 21 06-29-2007 09:25 PM
Ruby must run in c:\ruby in order to find libraries (xp sp2) zenix Ruby 0 04-28-2007 03:55 PM
Can I get this site to load properly in FF? The Waker Firefox 2 12-11-2005 10:14 AM
More American Graffiti: Properly Framed, Properly Scored? Scot Gardner DVD Video 0 09-02-2003 02:28 AM



Advertisments