-3

Since I've migrated from Leopard to Snow Leopard I get

$ ruby script/server 
Rails requires RubyGems >= 1.3.2. Please install RubyGems and try again: http://rubygems.rubyforge.org

the only way to make it work is:

$ /usr/bin/ruby script/server
=> Booting Mongrel
=> Rails 2.3.8 application starting on http://0.0.0.0:3000

So I guess something got broken with my path, here is my ~/.profile file fyi:


##
# DELUXE-USR-LOCAL-BIN-INSERT
# (do not remove this comment)
##
echo $PATH | grep -q -s "/usr/local/bin"
if [ $? -eq 1 ] ; then
    PATH=$PATH:/usr/local/bin
    export PATH
fi

export PATH=$PATH:/opt/local/bin
export MANPATH=$MANPATH:/opt/local/share/man
export INFOPATH=$INFOPATH:/opt/local/share/info

PATH="/usr/local/mysql/bin:$PATH"
PATH="/opt/local/bin:/opt/local/sbin:$PATH"
PATH="/usr/local/bin:/usr/local/sbin:$PATH"
export PATH

export GEMDIR=`gem env gemdir`

How can I fix this?

gsamaras
  • 71,951
  • 46
  • 188
  • 305
Leonardo Dario Perna
  • 1,045
  • 2
  • 10
  • 23
  • leo - if you change the title, this might just scrape thro without being closed [edit] - i see it has been changed :) – jim tollan Oct 26 '10 at 20:38
  • also echo $PATH. it appears that you can clean it up a lot as you wil have /usr/local/bin and /opt/local bin in there a couple of times. – Doon Oct 27 '10 at 00:00

2 Answers2

5

install RVM http://rvm.io/

Problem solved..

There is also number of other similar software: https://github.com/wayneeseguin/rvm/blob/master/help/alt.md

mpapis
  • 52,729
  • 14
  • 121
  • 158
Doon
  • 19,719
  • 3
  • 40
  • 44
  • This is indeed the most hassle-free solution! – Mark Thomas Oct 26 '10 at 23:53
  • Not only the most hassle-free solution, but it also allows you to use multiple rubies at once (e.g. 1.8.7, 1.9.2 and jruby). – Ariejan Oct 27 '10 at 14:25
  • @Doon: I've installed RVM | Inserted: [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" in my .bash_profile | Tested the whole thing: $ type rvm | head -n1 (return: rvm is a function) | But when I type: "$ rvm install 1.8.7" I got: ruby-1.8.7-p302 - #compiling Error running 'make ', please read /Users/leonardodarioperna/.rvm/log/ruby-1.8.7-p302/make.log There has been an error while running make. Halting the installation. (see the make.log here http://pastebin.com/vJ4kVm0U) – Leonardo Dario Perna Nov 24 '10 at 13:46
  • @Doon: BTW I've XCode 3.2.3 (1688), 64bit. – Leonardo Dario Perna Nov 24 '10 at 13:53
  • @Doon: I added [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session. at the end of my ~/.profile as well ...same error.Could it be a 32/64bit issue? – Leonardo Dario Perna Nov 24 '10 at 14:02
  • @Doon: yep, it was a 64bit nightmare, I fixed it adding: rvm_archflags="-arch x86_64" in my ~/.rvmrc – Leonardo Dario Perna Nov 24 '10 at 14:16
  • OSX doesn't have readline installed (it has a different lib). Follow the steps here. http://niwos.com/2010/03/19/rvm-on-osx-snow-leopard-readline-errors/ – Doon Nov 24 '10 at 14:20
  • NOW $ ruby script/server WORKS! @Doon you rule. Thank you for your infinite n00b-friendly patience :D! – Leonardo Dario Perna Nov 24 '10 at 18:01
  • One last thing: installing mysql 2.8.1... Error running 'GEM_HOME='/Users/leonardodarioperna/.rvm/gems/ruby-1.8.7-p302' GEM_PATH='/Users/leonardodarioperna/.rvm/gems/ruby-1.8.7-p302' gem install mysql -v2.8.1 ', please read /Users/leonardodarioperna/.rvm/log/ruby-1.8.7-p302/gem.install.log mysql 2.8.1 failed to install ( output logged to: /Users/leonardodarioperna/.rvm/log/ruby-1.8.7-p302/gem.install.log ) || gem.install.log = http://pastebin.com/JwR0bhnp – Leonardo Dario Perna Nov 24 '10 at 18:03
  • Well the problem is you are using mysql and not postgresql :) Do you have mysql server installed? and does the configure line for the mysql gem look correct. that pastebin doesn't appear to point to the correct log. But my guess is that you either don't have the server or the client libs installed for mysql.. – Doon Nov 24 '10 at 19:38
  • Some people got similar issues ... http://stackoverflow.com/questions/1357997/snow-leopard-ruby-1-9-1-mysql-gem-huge-problems – Leonardo Dario Perna Nov 28 '10 at 21:06
  • how did you install mysql? I am seeing that the gem will fail if you installed mysql using the DMG (As it is missing libraries.) Try installing mysql from macports (mysql5 mysql5-server) which will fill in the missing depends and should make the gem work.. – Doon Nov 29 '10 at 00:20
0

The last two PATH= lines appear to be the problem. There's a Ruby in your /usr/local/bin or /opt/local/bin directory and it's taking precedence over the system-installed one. I'm not sure why migrating to Snow Leopard would trigger this, since I don't believe it adds those lines to the file.

Doon's recommendation of RVM is not necessary, but it is a really handy tool.

Chuck
  • 234,037
  • 30
  • 302
  • 389
  • 1
    My guess is that pre snow leopard, OP had upgraded system ruby using gem update --system. Upgrade to snow leopard replaces the system ruby. My guess is gem path and the like are getting all messed up due the /usr/bin/rails file calling the ruby in system frameworks. When I upgraded to snow leopard I did a clean install and then migrated all my data over, rebuilt the dev environment (This was pre -rvm) now that I am using RVM. I leave the system ruby alone. – Doon Oct 26 '10 at 23:59
  • @Leonardo Dario Perna: Remove the last two PATH= lines, like I said. – Chuck Nov 23 '10 at 17:51
  • Thanks, I've commented the last two PATH= lines but nothing changed :( – Leonardo Dario Perna Nov 24 '10 at 13:10