5

Update II Problem Solved but Why? This has been the biggest headache ever. My problem is solved, however I have no clue how I accomplished this task. Plus the following results make no sense. My .profile path (/usr/local/bin) is different than the path that is currently working (/usr/bin/). The working path suddenly appeared after I closed terminal in OSX snow leopard. What is going on here?

Here is the working paths and confusing .profile file:

$ rails -v
Rails 3.0.0.beta
$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
$ gem -v
1.3.6
$ whereis ruby
/usr/bin/ruby
$ whereis rails
/usr/bin/rails
$ whereis gem
/usr/bin/gem
$ which gem
/usr/bin/gem
$ which ruby
/usr/bin/ruby
$ which rails
/usr/bin/rails
$ mate ~/.profile

.profile file:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
if [[ -s /Users/justinz/.rvm/scripts/rvm ]] ; then source /Users/justinz/.rvm/scripts/rvm ; fi

Update I notice that which ruby and whereis ruby are different locations

which ruby
/opt/local/bin/ruby
whereis ruby
/usr/bin/ruby

I recently upgraded ruby to ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10] and I think I broke rails. When I attempt to load rails. I get an odd message. Please help!

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

$ which ruby
/usr/local/bin/ruby
$ whereis ruby
/usr/bin/ruby
$ which rails
/usr/local/bin/rails
$ whereis rails
/usr/bin/rails
$ which gem
/usr/local/bin/gem
$ whereis gem
/usr/bin/gem
$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin10.2.0]
$ rails -v
Rails 2.3.5
$ gem list

*** LOCAL GEMS ***

actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (2.3.5)
builder (2.1.2)
bundler (0.9.11)
columnize (0.3.1)
erubis (2.6.5)
fastercsv (1.5.1)
ffi (0.6.3)
gbarcode (0.98.16)
i18n (0.3.5)
linecache (0.43)
mail (2.1.3)
memcache-client (1.8.0)
prawn (0.8.4)
prawn-core (0.8.4)
prawn-layout (0.8.4)
prawn-security (0.8.4)
rack (1.1.0, 1.0.1)
rack-mount (0.6.1)
rack-test (0.5.3)
rails (2.3.5)
rake (0.8.7)
ruby-debug (0.10.3)
ruby-debug-base (0.10.3)
rubygems-update (1.3.6)
sqlite3 (0.0.8)
text-format (1.0.0)
thor (0.13.4)
tzinfo (0.3.17)
$ sudo gem install sqlite3-ruby
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3-ruby:
    ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb
checking for fdatasync() in -lrt... no
checking for sqlite3.h... yes
checking for sqlite3_open() in -lsqlite3... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/local/bin/ruby
    --with-sqlite3-dir
    --without-sqlite3-dir
    --with-sqlite3-include
    --without-sqlite3-include=${sqlite3-dir}/include
    --with-sqlite3-lib
    --without-sqlite3-lib=${sqlite3-dir}/lib
    --with-rtlib
    --without-rtlib
    --with-sqlite3lib
    --without-sqlite3lib


Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.5/ext/sqlite3_api/gem_make.out
JZ.
  • 21,147
  • 32
  • 115
  • 192

6 Answers6

2

Have you looked into the Ruby Version Manager or rvm ( http://rvm.beginrescueend.com/ ). I know that it runs on linux and Mac OS X.

Basically it is a tool that manages different versions of ruby and all its associated "pieces". I was having similar problems when a friend recommend I try it, and it solved it for me.

civrot
  • 36
  • 2
1

I just fixed this same issue. I'm not sure its the most efficient, but I rebuilt everything from scratch as detailed on hivelogic, installing ruby and ruby gems to '/usr/local'

Remembering to change my path:

export PATH=/usr/local/bin:$PATH
ethyreal
  • 3,659
  • 2
  • 21
  • 25
  • can you please explain the export path? How does one change it? I followed all of the steps on the snow leopard install, initially it worked, followed by a restart I have the same problem. – JZ. Mar 15 '10 at 01:25
  • the path is basically where the shell/terminal program looks when you type commands for instructions on how to process those commands. When you rebuilt ruby from the tutorial it installed everything in /usr/local so here you are prepending it to the list of directories it checks, so it looks there first. – ethyreal Mar 15 '10 at 07:19
  • if you type the export command in the terminal it exists for that session only, which is why you add the line to the end of your .profile or .bash_login file in your home directory so every time you start the terminal it will load the command, but i guess you could also just enter the export command manually everytime you start the shell.. – ethyreal Mar 15 '10 at 07:22
  • you can check to make sure you've added it right by typing "echo $PATH" and the first thing should be /usr/local/bin then some other paths. It checks the directories from left to right. Good luck. – ethyreal Mar 15 '10 at 07:25
1

If you're running this on a mac (which i'm guessing from the 'darwin' that appears in your traces), you can sometimes get issues like this if you've sometimes typed gem whatever instead of sudo gem whatever. Check your ~/.gem or ~/.gems directory to see if any gems have accidentally been installed there.

If so, delete/reinstall them.

corprew
  • 1,991
  • 14
  • 17
0

I'm not entirely sure that I remember correctly as it was a while ago, but I think I had a similar problem when I upgraded from Rails 2.3.4 to Rails 2.3.5. In that case I believe the problem was caused by having both Rack 1.1.0 and Rack 1.0.1 installed (Rack 1.1.0 got installed during the Rails upgrade). I got rid of 1.1.0 and things started working again.

I didn't run into any issues when I upgraded from Ruby 1.8.6 to Ruby 1.8.7 (on Windows).

I could be wrong but perhaps this will at least give you a new direction to try.

Alex Korban
  • 14,916
  • 5
  • 44
  • 55
0

I actually just encountered this problem as well. Mine was caused by upgrading ruby. I was starting with a somewhat old EC2 AMI running Ruby 1.8.6, and I wanted to run on a newer 1.8.7. I downloaded and compiled the latest 1.8.7 Ruby, removed the link to my 1.8.6 (this is a Debian server so /usr/bin/ruby was a symlink to /usr/bin/ruby1.8, beware of that), and had the new Ruby running from /usr/local/bin/ruby. That was okay. But then I started running into weird behavior, including the aforementioned "Rails requires RubyGems >= 1.3.2" error. Here were the things I ended up needing to check and do, which could vary for others but hopefully this will be helpful:

  • I removed rubygems and reinstalled it: "apt-get remove rubygems" followed by downloading it from rubyforge and installing. This might not be completely needed, but I wanted to make sure things were clean. Remember that the gems are associated with your ruby version, so with the upgrade you may need to reinstall all the gems anyway. I'm not sure if there's a workaround for this, but I'd be interested to know if so.

  • In my case, I cheated. Since I was going from 1.8.6 -> 1.8.7, I decided to try copying the gems from the old Ruby location to the new one: "cp -R /usr/lib/ruby/gems/1.8 /usr/local/lib/ruby/gems". It worked for me, but I'm still testing and it's conceivable one could run into problems doing this so be careful. It's certainly more convenient than reinstalling everything, of course.

  • I'm running passenger with nginx. In the Passenger config, it will have entries pointing to both the Ruby binary and the Passenger gem. Make sure to change these! It took me a couple of minutes of wondering how my app was still starting properly even though the gems were gone... It was because nginx's config was still pointing directly to /usr/bin/ruby1.8 -- oops.

Hope this info helps someone.

Masonoise
  • 1,573
  • 3
  • 14
  • 28
-3

you need to create a symbolic link between the two different directories.

sudo ln -s /opt/local/bin/ruby /usr/bin/ruby

mike
  • 1
  • 1
  • Bad idea. Looks like he's on a Mac, and doing that will clobber the system-installed Ruby, which could cause problems elsewhere. – mipadi Mar 15 '10 at 16:37
  • what should I do to undo this command? I executed it yesterday :( – JZ. Mar 16 '10 at 02:40
  • @JZ to undo the command sudo rm -rf /usr/bin/ruby @mipadi I understand that he is on a mac. I have executed this same exact command on my mac machine before and it has worked fine. I do not see how it could even cause problems when all it does is create a link to the directory, it does not actually move any files or folders. So where would the problems come from? He must have used the command i told him to use anyways because it looks like the problem is solved. You have absolute no idea what you are talking about. – mike May 11 '10 at 00:13
  • `/usr/bin/ruby` *isn't* a directory, it's a link to the Ruby executable. It might not cause problems, but it *could* -- `/usr/bin/ruby` links to the Apple system Ruby, which may be used by some system utilities (now or in the future); if the MacPorts version differs, this can cause problems. Nuking it via `sudo rm --f /usr/bin/ruby` could cause problems, too. You shouldn't alter or remove the system binaries without at least explaining *what* the user is doing and the problems that could pop up. – mipadi May 11 '10 at 03:53