Michael Giovanni Pumo
Michael Giovanni Pumo

Reputation: 14774

How do I upgrade Rails?

I am new to Ruby and Rails, as well as all this command line melarky. So please bear with me.

I have installed, RubyGems, Homebrew, RVM, Rails etc, by following various tutorials.

I think I have all of this going now, but when I type:

rails --version

I get, 3.2.12. I notice that Rails 4 is out. How do I upgrade to this version?

If I do:

gem install rails

Even doing:

gem update rails

I still get 3.2.12.

Any ideas?

UPDATE

When trying a few options here, I get this message returned...

Michaels-MacBook-Pro:~ ParanoidAndroid$ gem install rails --version=4.0
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
*** 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/rvm/rubies/ruby-1.9.3-p392/bin/ruby
    --with-atomic_reference-dir
    --without-atomic_reference-dir
    --with-atomic_reference-include
    --without-atomic_reference-include=${atomic_reference-dir}/include
    --with-atomic_reference-lib
    --without-atomic_reference-lib=${atomic_reference-dir}/lib
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
    from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:712:in `try_run'
    from extconf.rb:26:in `<main>'


Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p392/gems/atomic-1.1.14 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p392/gems/atomic-1.1.14/ext/gem_make.out

Seems there's an error happening. Any further ideas?

Thanks again everyone!

Upvotes: 26

Views: 60630

Answers (7)

AlbaSpot.com
AlbaSpot.com

Reputation: 1

I just needed to upgrade to the latest version and gem update rails did the trick on Ubuntu

Upvotes: 0

Purple Hexagon
Purple Hexagon

Reputation: 3578

If you are using RVM then you should create a seperate gemset first like:

rvm gemset create whateverName

in this example I will install rails 4

rvm install 2.0.0

rvm list  

rvm 2.0.0 

^^^^(you may need to copy and paste the version number exactly here as it was displayed in rvm list)

rvm gemset create rails4

rvm gemset use rails4

add the following to your gemfile for existing apps

gem 'rails', '4.0.0'

then run

bundle update rails

or do following to just install the gem

gem install rails --version=4.0

UPDATE

If you havne't installed Xcode 4.5 CLI tools then you will need to

Preferences > Downloads > Components

DMG

https://developer.apple.com/downloads

you may then also need to use homebrew to update gcc

brew install apple-gcc42

the following link has all the information you will need:

https://thoughtbot.com/blog/the-hitchhikers-guide-to-riding-a-mountain-lion

Upvotes: 15

k clark
k clark

Reputation: 1

Best to use gem list --remote --all. Unless your looking for that particular version as long as the gemset for that project has been established

Upvotes: 0

thisismydesign
thisismydesign

Reputation: 25072

If you already have a Rails project you should:

  • Specify the desired version in your Gemfile (e.g. gem 'rails', '~> 5.2.0.rc1')
  • Run bundle install (bundle update may be needed)
  • Run rails app:update (rake rails:update for 4.2 and earlier)
  • Follow instructions on screen
  • Follow the official guide for additional steps depending on your version

Upvotes: 30

Pravin Mishra
Pravin Mishra

Reputation: 8434

You can install either with specific version OR putting gem version in itself Gemfile.

gem install rails -v 4.0.0

Upvotes: 4

juco
juco

Reputation: 6342

You can get a list of all gem versions with

gem list rails --remote --all

To install specify version 4.0.1 for example you can use

gem install rails -v 4.0.1

Or you could just specify the version in your Gemfile

Upvotes: 1

janfoeh
janfoeh

Reputation: 10328

gem update rails does nothing for you, because bundler makes sure that only the gems specified in your Gemfile are loaded and used.

So in order to upgrade to Rails 4, you need to change the Rails version number in your Gemfile and run bundle update rails.

This Railscast guides you through all the steps of manually updating an existing application from Rails 3.2 to Rails 4:

http://railscasts.com/episodes/415-upgrading-to-rails-4

Upvotes: 6

Related Questions