I'm upgrading an existing setup to use Rails 5 beta 3. As part of that, I've upgraded Ruby to version 2.2.4 (using RVM), i.e.
rvm install 2.2.4
rvm use 2.2.4
With that done, I'm trying to install the Rails gem. However, running
sudo gem install rails
gives me the error
ERROR: Error installing mime-types-data: mime-types-data requires Ruby version >= 2.0.
Having read this question, I've looked at my Ruby versions:
ruby --version => ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
sudo ruby --version => ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
I don't seem to be able to access RVM from sudo
, so I tried using gem install rails
instead, which also fails while building native extensions:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/home/ubuntu/.rvm/rubies/ruby-2.2.4/bin/ruby -r ./siteconf20160405-31973-l7bzq7.rb extconf.rb
checking if the C compiler accepts ... *** 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=/home/ubuntu/.rvm/rubies/ruby-2.2.4/bin/$(RUBY_BASE_NAME)
--help
--clean
/home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:571:in `block in try_compile'
from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:522:in `with_werror'
from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:571:in `try_compile'
from extconf.rb:80:in `nokogiri_try_compile'
from extconf.rb:87:in `block in add_cflags'
from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:619:in `with_cflags'
from extconf.rb:86:in `add_cflags'
from extconf.rb:336:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/nokogiri-1.6.7.2 for inspection.
Results logged to /home/ubuntu/.rvm/gems/ruby-2.2.4/extensions/x86_64-linux/2.2.0/nokogiri-1.6.7.2/gem_make.out
I see two solutions to this:
- Upgrade the Ruby that's used in
sudo
commands to 2.0 or above (preferably 2.2.4). I can't figure out how to do this, becausesudo rvm
results in command not found for rvm. - Fix the error that comes up when using
gem install rails
. Again, I don't know how to do this.
Which of these is the easiest (or is there an easier fix), and how do I do it?