RubyCocoa problem: No such file to load -- osx/objc/cocoa

Hi,

I’m trying to get RubyCocoa to work with ruby 1.8.0 on MacOS 10.2.8.

I followed Simon’s advice and unchecked libruby-static.a in the
RubyCocoa framework project file. Then I reinstalled both RubyCocoa and
ruby, but no go. The RubyCocoa tests still fail with the now familiar
error message:

/usr/local/lib/ruby/site_ruby/1.8/osx/cocoa.rb:12:in `require’: No
such file to load – osx/objc/cocoa (LoadError)

Unfortunately, I’m not very familiar with the C toolchain, and so far
couldn’t find out more about this problem.

Can anyone help?

Thanks in advance,
-Ralph.

Simon wrote:

···

I figured this out. Below is the email I sent to the contact email for
RubyCocoa but I didn’t get any reply. Anyway, all you need do is open
the Framework project file in ProjectBuilder and clear the linking of
libruby-static by deselecting the check box. But this does mean that
when you build apps you will need to explicity link in libruby-static.
Hope this helps.

The problem was that libruby-static got linked twice: once with ruby
and once with the RubyCocoa framework. This meant that each got their
own versions of the global variables defined in libruby-static - the
problem being the variable rb_load_path - you prepend the Framework
path to this in RBRuntime.m but because libruby-static was linked into
RubyCocoa framework the newly prepended directory only goes on that
copy of rb_load_path - not the rb_load_path used in the ruby
interpreter. I fixed this (eventuallY - when I found the reasons) by
removing the link of libruby-static in the framework project files.
This worked fine - but it means that when applications are built and
linked with the framework you also need to link libruby-static (an
extra lib on the link line)

Barry Shultz wrote:
Hi,

Pardon the attachment, but this issue has been brought up before with
no
resolution (that I know of), so I have tried to include any possibly
relevant info in the attached file.
I have been unable to get RubyCocoa to work with Ruby 1.8 on OS X (I
did
not try to get it running with the pre-installed 1.6.7, because of
problems with Array#pack that I brought up last week on the ML).
At the end of the attached file, you’ll see that RubyCocoa does not
successfully run its unit tests, and I get the error shown in the
subject. I have tried to include all relevant information about my OS
and my install of RubyCocoa.
I would be happy to provide any other information, if someone will
help
me solve this one.

I followed Simon’s advice and unchecked libruby-static.a in the
RubyCocoa framework project file. Then I reinstalled both RubyCocoa
and ruby, but no go.

I think RubyCocoa works for the Ruby 1.6.7 installed with Mac OS X and
with the binary distribution of RubyCocoa, but I don’t know if it works
for all Mac OS X versions.

The RubyCocoa tests still fail with the now familiar error message:
/usr/local/lib/ruby/site_ruby/1.8/osx/cocoa.rb:12:in `require’: No
such file to load – osx/objc/cocoa (LoadError)

You can track down the required directories and files on your system.
These are ‘osx/objc/cocoa.rb’ and files referenced in ‘cocoa.rb’. As I
recall there is a copy in the Library/Frameworks/RubyCocoa directory or
a subdirectory thereof. You can search your hard drive for ‘cocoa.rb’
and find it.

Then you can either (1) reference the correct location in the Ruby
programs requiring these files or (2) copy them to the location
referenced in the Ruby programs requiring these files.

Either way, once you do this, you’ll get a real error referencing a
missing Objective C superclass (or something like that, I forget all of
the details). I have never gotten beyond that point.

If you have better luck, I am sure there are several people who would
be interested in hearing about it.

Regards,

Mark

Hi,

Either way, once you do this, you’ll get a real error referencing a
missing Objective C superclass (or something like that, I forget all
of the details). I have never gotten beyond that point.

Right, I can avoid the LoadError by specifying the correct include path
on the command line, but for some reason, class ObjcID seems not to be
defined:

$ ruby -r’rubycocoa’ -e ‘puts “OK”’
OK
$ ruby -r’rubycocoa’ -r ‘osx/cocoa’ -e ‘puts “OK”’
/usr/local/lib/ruby/site_ruby/1.8/osx/cocoa.rb:12:in require': No such file to load -- osx/objc/cocoa (LoadError) from /usr/local/lib/ruby/site_ruby/1.8/osx/cocoa.rb:12 $ ruby -I/Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby -r'rubycocoa' -r 'osx/cocoa' -e 'puts "OK"' /Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/ objc/oc_object.rb:15: undefined superclass ObjcID’ (TypeError)
from
/Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/
objc/oc_all.rb:13:in `require’

Cheers,
-Ralph.