19 Oct 2009, 17:40
Generic-user-small

Gregory Clarke (15 posts)

On Leopard, after using the path-setting.rb script, Gem.path contains /System/Library/Frameworks/Ruby.framework/… and /path/to/RubyCocoa.app/Contents/Resources/third-party/gems as expected. On Snow Leopard, Gem.path contains the user’s .gem folder, /Library/Ruby/Gems, then the two folders above.

Unfortunately I don’t know enough about RubyGems yet to understand what the script is doing. However, I’ll share how I found the problem and what it might mean.

My rubycocoa app uses a gem called nokogiri that compiles at install. On Leopard the bundle has both ppc and i386 architectures; on Snow Leopard the bundle is x86_64 only, because ruby runs as 64 bit. For the gem included in the app bundle I compiled it with all 3 architectures.

The app crashes on launch because it can’t find the right architecture for the gem, which is how I found it was using the gem in /Library instead of the app bundle. But it also means that the rubycocoa app is running as 32 bit (which Activity Monitor shows). I wonder why?

08 Dec 2009, 18:31
England-small_pragsmall

Brian Marick (56 posts)

Sorry I didn’t reply earlier. I messed up my RSS subscription to this forum.

I will take a look at this. However, I believe that nokogiri doesn’t work under Ruby 1.8.7, which is what Apple ships.

08 Dec 2009, 19:21
England-small_pragsmall

Brian Marick (56 posts)

On Snow Leopard with 1.3.1 (which I believe is an update to what Apple delivers. to be safe, use ‘sudo gem update –system’), I replaced the existing make_chosen_libs_and_gems_available in path-setting.rb with this:

def self.make_chosen_libs_and_gems_available $: « root_for_ruby_files + “/third-party/lib” Gem.use_paths(nil, [root_for_ruby_files+ “/third-party/gems”, APPLE_GEM_HOME]) end

It seems to work, though I haven’t tried it out very thoroughly.

09 Dec 2009, 21:05
Generic-user-small

Gregory Clarke (15 posts)

Thanks Brian - this works for me on Snow Leopard. I haven’t updated Snow Leopard’s rubygems, but it is running version 1.3.1.

02 Apr 2010, 22:20
Generic-user-small

Wolfgang Kittenberger (7 posts)

the changed version of make_chosen_libs_and_gems_available allows to request successful the gems installed in “…./third-party/gems” on Snow Leopard, but it does NOT isolate the “other” gems as intended.

I experimented with this code, but I could not find a way to convince the rubygems subsystem (gem - version 1.3.5/gemcutter - version 0.2.1) to “forget” the standard paths, neither with Gem.clear_paths, nor with removing the “/Library/Ruby/Gems/1.8/gems/gemcutter-0.2.1/lib/” entry from the $LOAD_PATH before leaving the make…. method.

Any ideas?

03 Apr 2010, 20:05
Generic-user-small

Gregory Clarke (15 posts)

Somewhere along the line I changed my path-setting.rb file as follows. Under the line: ENV[‘GEM_HOME’] = root_for_ruby_files + “/third-party/gems” I’ve added the line: Gem.use_paths(nil, [ENV[‘GEM_HOME’], APPLE_GEM_HOME])

This seems to work for me. The RubyCocoa app can use both the third-party/gems you’ve added and the standard Library/Ruby/Gems (such as hpricot).

03 Apr 2010, 21:19
Generic-user-small

Wolfgang Kittenberger (7 posts)

I understood the intention of the make_chosen_libs_and_gems method so, that only gems distributed by Apple and those installed in the /third-party/gems directory could be required. This should avoid our application to fail on another system when the required gems are not installed there. And it works so under Leopard, but not under Snow Leopard.

04 Apr 2010, 00:41
Generic-user-small

Gregory Clarke (15 posts)

Right, and the modified code works for me under Snow Leopard. Here’s the whole modified method in case I’ve forgotten something:

def self.make_chosen_libs_and_gems_available $: « root_for_ruby_files + “/third-party/lib” RbConfig::CONFIG[‘sitelibdir’] = $:.last # Rubygems uses this unless require ‘rubygems’ Gem::ConfigMap[:sitelibdir] = $:.last end Gem.clear_paths ENV[‘GEM_HOME’] = root_for_ruby_files + “/third-party/gems” Gem.use_paths(nil, [ENV[‘GEM_HOME’], APPLE_GEM_HOME]) # Snow Leopard end

04 Apr 2010, 04:54
Generic-user-small

Wolfgang Kittenberger (7 posts)

Thanks Gregory - this works for me too!

  You must be logged in to comment