views:

280

answers:

2

I'm running Snow Leopard, and installed a custom built Ruby according to the guide here: http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard . My ruby binary lives in usr/local/bin/ruby and my gems are installed in /usr/local/bin/gem . My gem env looks like so:

RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0] - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8 - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby - EXECUTABLE DIRECTORY: /usr/bin

I think I may have borked the install since all actions taked on gems give the error:

ERROR: While executing gem ... (Errno::EEXIST) File exists - /usr/local/bin/ruby

How do you edit the environment variables for the gem environment? And for those of you on OS X and using ruby AND gems, what did you use to get yourself up and running? I'm thinking of just nuking everything and starting anew.

A: 

It looks like your installation of ruby into /usr/local/bin is not the ruby that you're getting, which probably means /usr/local/bin/ is not in your PATH. If you'd like to run that ruby, try editing your .bash_profile to add /usr/local/bin like this:

export PATH=/usr/local/bin:$PATH

Alternately, you can add the path to a file in /etc/paths.d, which is the preferred method for adding paths globally on an OS X system.


I've tried things about three different ways, each with varying results. I have systems with the default install (/usr/bin), hand-built /usr/local/bin and also Mac Ports in /opt/local/bin.

By far, the simplest is to just use the built-in binary, which on 10.6.2 is ruby 1.8.7. In that scheme, gems are installed in /Library/Ruby/Gems. Second simplest is MacPorts (sudo port install ruby), third is the totally from source method you're describing above. Certainly there are good reasons people install from source, but unless you're trying to run ruby 1.9 or another version, you're best off using the built-in ruby 1.8.7.

Jess Bowers
Thanks for this. My path is like so:>/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/users/aegir/.gem/ruby:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/binSo usr/local/bin is in my path. But I had not figured that gems come with the install. Most probably the gem environment is confused since the gem library is in the System/Library/Frameworks but my ruby binary is in usr/local/bin . Im probably better off just deleting the binary there and pointing everything to the default paths.
akarnid
The error he is getting seems to suggest that gem is trying to write something to /usr/local/bin/ruby
Steve Weet
A: 

Does the command "gem env" not report any gem paths? Mine reports a number of gem paths along with teh version of rubygems etc. that yours does not appear to be doing.

RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.5
  - RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-10
  - GEM PATHS:
     - /Library/Ruby/Gems/1.8
     - /Users/steveweet/.gem/ruby/1.8
     - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/

You can edit the environment variables associated with gem by specifying them in your shell startup files, (.bashrc for bash). The relevant variables are all listed in the environment page of the gem web site. You will want to pay particular attention to GEM_HOME and GEM_PATH. You can check the current settings of these by typing echo $GEM_HOME at a shell profile

I would suggest that your best action at this moment in time may be to go back to your default ruby installation as provided with OS/X and then download and install rvm (The Ruby version manager) and then watch Ryan Bates screencast

Steve Weet