2

I'm trying to install Rails on Ubuntu:

sudo gem install rails

but I'm having trouble:

Building native extensions.  This could take a while...
ERROR:  Error installing rails:
  ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
  from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
  from extconf.rb:1:in `<main>'


Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/json-1.7.7 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/json-1.7.7/ext/json/ext/generator/gem_make.out

What is the problem?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • 4
    how did you install ruby? Was is the ubuntu default version using apt-get? If so, you may need to install the `-dev` package as well, and ensure that you have installed `build-essential` – Daniel Evans Feb 19 '13 at 23:42

2 Answers2

12

As Daniel said in the comments, try and execute sudo apt-get install ruby-dev

StackExchange User
  • 1,222
  • 14
  • 35
0

Try it, I have installed successfully on Ubuntu 12.4(You can choose versions during installation, According to your requirements....)

  1. sudo apt-get update
  2. sudo apt-get install build-essential git-core curl libmysqlclient18 nodejs

  3. sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) umask g+w

  4. source /etc/profile.d/rvm.sh

  5. sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

  6. sudo chown -R [user]:[user] /usr/local/rvm Example : sudo chown -R rohitporwal:rohitporwal /usr/local/rvm

  7. source /usr/local/rvm/scripts/rvm

  8. rvm install 1.9.2

  9. sudo gem install rails

Gopal S Rathore
  • 9,885
  • 3
  • 30
  • 38