problems with multiple Ruby installations
Stephyn G W ...
1 post
|
I typed the following code from the book:
require 'osx/cocoa'
include OSX
class AppDelegate < NSObject
def applicationDidFinishLaunching( aNotification)
puts "#{aNotification.name} makes me say: Hello, world!"
puts "#{aNotification.object} is the object notifying"
end
end
NSApplication.sharedApplication
NSApp.setDelegate( AppDelegate.alloc.init)
NSApp.run
and received the following error when I ran it: $ ruby basic.rb 2008-06-18 12:01:36.728 ruby[5702:10b] WARNING: multiple libruby.dylib found: '/usr/local/lib/libruby.dylib' and '/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/libruby.1.dylib' 2008-06-18 12:01:36.730 ruby[5702:10b] RBCocoaInstallRubyThreadSchedulerHooks: warning: rb_set_cocoa_thread_hooks is linked from a different library (/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/libruby.1.dylib) than ruby_init (/usr/local/lib/libruby.dylib) Segmentation fault This occurs basically because I have two different Ruby installations. $ which ruby /usr/local/bin/ruby and the one that is pointed to by /usr/bin/ruby in /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/. I’m still trying to work out what the “right” thing to do is. I use the /usr/local/bin/ruby version for work. For now, I’m just prepending: #!/usr/bin/ruby to my scripts, making them executable with chmod 755 and viola: $ ./basic.rb NSApplicationWillFinishLaunchingNotification says that the application will finish launching. NSApplicationDidFinishLaunchingNotification makes me say: Hello, world! <NSApplication: 0x510dd0> is the object notifying everything works as expected. It isn’t an ideal solution but works and might help someone who runs into the same problem. Cheers, |
Brian Marick
27 posts
|
Most of the Ruby in the book is run as part of a OSX app, not an independent script, so your solution probably suffices. I believe a regular app will pick up the right Ruby. If not, mail me at marick@exampler.com It’s possible you might also have problems with multiple RubyCocoa installations. Here’s some text from the upcoming beta2 that might help: I also have many of the examples log RubyCocoa’s version to the console (visible via the Console app). If you manually installed a version of RubyCocoa before you installed Leopard, that old version may be loaded in preference to Leopard’s (by an application, but not by <commandname>irb</commandname>). See <pref linkend="id.gotchas" /> if samples behave oddly, you check the console, and the version is old. </p> <p> If your application logs version to the console and the version is older than that gotten from IRB, probably installed version before leopard. If there's a version in /Library/Frameworks/RubyCocoal.framework, delete it. </p> |
Brian Marick
27 posts
|
Whoops – didn’t copy the important bit, which comes before the last para above: To see what version of RubyCocoa you’re running, type this to <commandname>irb</commandname>:
irb(main):001:0> require 'osx/cocoa'
=> false
irb(main):002:0> OSX::RUBYCOCOA_VERSION
=> "0.13.1"
|
3 posts, 2 voices
