Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I upgrade the Ruby version of my project?

I recently started learning Rails using Ruby 1.9.3p385, and I'm trying to develop a small project with it.

I'm using Linux so I installed Ruby using RVM.

I developed a few pages, following some tutorials. I would like to upgrade my project to use Ruby 2.0.0. What do I have to do?

I installed Ruby 2.0.0 with RVM:

rvm install 2.0.0

Everything seems OK, so I tried to use it:

rvm use 2.0.0-p247

But when I try to run my Rails server using rails server, I get the following message:

bash: rails : command not found

I've read the RVM documentation about upgrading Ruby but I don't really understand what it does; I'm afraid of breaking everything.

Does it will upgrade my project in a way it will use Ruby 2.0.0 or what should I do?

Next, I will want to upgrade also to Rails v4.

like image 404
Tomane Avatar asked Feb 15 '23 12:02

Tomane


2 Answers

Your gemset which comes with new Ruby version is empty. Try this:

gem install bundler # this will install bundler
bundle # this will use bundler to install required gems
rails server
like image 153
Marek Lipka Avatar answered Feb 23 '23 23:02

Marek Lipka


Did you run rvm use 2.0.0-p247 or did you use rvm use 2.0.0-p247 --default? The later will set Ruby v.2.0 as the default for your system. Failure to do that will revert your Ruby to whatever RVM's default is the next time you log into your system or open a new terminal window.

When RVM installs a new version of Ruby, it installs only the default gems. It CAN upgrade a Ruby to another version, and optionally install the existing gems as it does so, but that's not what you asked it to do: rvm install 2.0.0 only installs Ruby. At that point you have to install the other gems you need, which would include Rails.

My general practice when installing various versions of Ruby and the gems I like is to use two command-line pipes to dump my existing gems, then (re)install them. First I switch to an existing Ruby whose gems I want to duplicate, then run:

gem list | cut -f1 -d' ' > ~/gem_list

Then I switch to the newly installed one, and run this:

xargs gem install < ~/gem_list

This does a completely clean install of the gems, outside of RVM's commands.

Why? Habit. Paranoia based on some "experiences" I had in the past with RVM.

Once that's all done and I have brand-spanking-new Ruby and gems, I'll proceed with running bundler or other housekeeping chores.

like image 43
the Tin Man Avatar answered Feb 23 '23 22:02

the Tin Man