Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3: Ruby 1.9.2: does it need /usr/bin/ruby1.8?

I am trying to get the Rails tutorial by Michael Hartl going. I spent a lot of time fighting various libraries. So I removed all ruby software from my Ubuntu 10.4 system.

Then I installed Ruby 1.9.2.

 $ ruby -v
 ruby 1.9.2dev (2010-07-02) [i486-linux]

So far so good. Then I did

 sudo gem install rails

After a long time, it finished the installation. Then I ran

 $ rails -v
 bash: /usr/bin/rails: /usr/bin/ruby1.8: bad interpreter: No such file or directory

So...I have no /usr/bin/ruby1.8 on my system. How do I get Rails 3.0.3 to use my ruby at /usr/bin/ruby?

I appreciate any help you can give me.

Just to see if I could keep going, I tried

 $ cd /usr/bin
 $ sudo ln -s ruby1.9.2 ruby1.8

This let me keep going, but is it the right thing to do?

like image 577
Jay Godse Avatar asked Dec 16 '10 20:12

Jay Godse


2 Answers

It took trying 3 different methods of installing and uninstalling Ruby, but I finally got it!

I found a great tutorial by Toran Billups which gives some great instructions. After analyzing what he did, it comes down to a few key concepts:

  1. Some libraries that are independent of the Ruby version must be installed in the system (using "sudo apt-get").
  2. Use RVM to install Ruby in your own account. i.e. no "sudo".
  3. Use gem to install gems in your particular ruby environment. (i.e. no "sudo"). When you set 1.8 as the Ruby environment, the gems are installed in the RVM 1.8 tree in your environment. When you set 1.9.2 as the environment, gems are installed in the 1.9.2 tree in your environment.

Here, then, is the process.

  1. Remove all Ruby programs (1.8.x and 1.9.2) and Ruby libraries from your Ubuntu 10.4 system.
  2. Install RVM on your system, following the instructions at the RVM site(broken) RVM site.
  3. Follow Toran Billups' tutorial, starting at the point where you install Ruby 1.8.7.
  4. Follow the instructions at Michael Hartl's tutorial(broken) Michael Hartl's tutorial to get Rails 3.0 working with Ruby 1.9.2, github, heroku.com, rspec, spork, and autotest.
like image 187
Jay Godse Avatar answered Oct 05 '22 14:10

Jay Godse


I had the same error after installing with RVM and opening new shells. The solution was to run:

$ rvm use 1.9.2 --default

P.S.
I'm running Ubuntu 10.04 and after two days of trial and error finally got rails 3 working with ruby 1.9.2. I highly recommend using RVM to install ruby a godsend!

like image 29
giftedwarrior Avatar answered Oct 05 '22 15:10

giftedwarrior