views:

60

answers:

1

NOTE: user377519 (answer below) pointed me in the right direction. I've posted the 'fix' at the bottom of the questions, in case you found this and need more than a 'pointer'

I can't figure out why the second call to "gem env" doesn't have the same environment as the first? Any pointers? This is driving me crazy!!!!

$ which gem

/usr/local/bin/gem

$ /usr/local/bin/gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.8 (2010-06-26 patchlevel 1) [i386-darwin9.8.0]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-darwin-9
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/1.8
     - /Users/pauliprice/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["http://gems.rubyforge.org/", "http://gems.github.com", "http://gems.github.com"]
  - REMOTE SOURCES:
  - http://gems.rubyforge.org/
  - http://gems.github.com
  - http://gems.github.com

$ gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.6 (2009-06-08 patchlevel 369) [universal-darwin9.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-9
  - GEM PATHS:
     - /Library/Ruby/Gems/1.8
     - /Users/pauliprice/.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
     - :sources => ["http://gems.rubyforge.org/", "http://gems.github.com", "http://gems.github.com"]
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/
     - http://gems.github.com
     - http://gems.github.com

SOLUTION:

Given that you don't (as I do not) want to switch between different versions, merely install a new version, on you OSX 10.5 box, this is how to get RubyGems installed correctly.

Assuming you built and installed your new Ruby like this:

./configure --prefix=/usr/local --enable-pthread
sudo make
sudo make install

edit your ~/.bash_profile and add this line

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

Save and refresh your terminal. Then you should install RubyGems like this:

Download and setup latest rubygems

wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
tar -xzv http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
cd rubygems-1.3.7
sudo su
# export PREFIX=/usr/local
# export GEM_HOME=$PREFIX/lib/ruby/gems/1.8
# export RUBYLIB=$PREFIX/lib/ruby:$PREFIX/lib/site_ruby/1.8
# ruby setup.rb all —prefix=$PREFIX
exit

edit ~/.bash_profile and add the following lines

export PREFIX=/usr/local
export GEM_HOME=$PREFIX/lib/ruby/gems/1.8
export RUBYLIB=$PREFIX/lib/ruby:$PREFIX/lib/site_ruby/1.8

And you're all good. Refresh Terminal,

A: 

Ruby and its tools are "smart." They are aware of execution context and will look for configurations based on where they are started. The first execution is out of a system directory, while the later is out of your home directory.

Given that you have two different versions and you're on Mac, it means you had to have either installed Ruby manually or through RVM. Given that the newer version is out system directory, I guess that you attempted to install a newer version of Ruby manually and am now confused why it's not working for you. You installed it into system space, but did not update Ruby's configuration in your home directory. Unfortunately, I have no answer how to get you out of this position. Hopefully, you have something that will let you undo your install.

The far safer way of installing different copies of Ruby is to use Ruby Version Manager (RVM). It does all the magic necessary to install multiple copies of Ruby without changing the system. From the command line you can invoke using a different interpreter for that session. Thus, system stays untouched but you can run JRuby, v1.9.2, etc.

Hope this gets you in a direction.

Thank you -- it led me to a FAQ: http://docs.rubygems.org/read/chapter/15#page101 that lead me to a solution.I added the solution to the question, to be able to use the code formatting options.
marfarma
btw: OS X has the system ruby in /usr/bin -- putting the new Ruby in /usr/local/bin _is_ installing a new copy without 'changing the system'
marfarma