djowinz
djowinz

Reputation: 356

Rails failing when attempting to install from gem 1.9.2

I am attempting to install RoR on my Lubuntu box just setup today, I have installed all of the rvm requirements installed Ruby. When I go to install rails I keep getting this error.

Running the command sudo gem install rails -V it looks like it's trying to pull source for ruby 1.9.1 but I have 1.9.2 and then it fails out cannot load such file --mkmf (LoadError).

Any help would be much appreciated, this is my first adventure into Ruby so this is my first setup. Ask any questions and I will answer.

enter image description here

Upvotes: 0

Views: 141

Answers (3)

Dan K.K.
Dan K.K.

Reputation: 6094

First, you need some RVM preinstallations, open terminal and type:

$> sudo apt-get install curl git ruby1.8

Then download and install RVM itself:

$> curl -L get.rvm.io | bash -s stable

After installing is done, load RVM:

$> source ~/.rvm/scripts/rvm

To check that RVM is installed as a function, type:

$> type rvm | head -1

(it should output "rvm is a function")

In order to work, RVM has some of it's own dependencies that need to be installed. You can see what these are using:

$> rvm requirements

For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:

$> sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config

Once you are using RVM, installing Ruby is easy:

$> rvm install 1.9.3

In newer version of Rails, you also need a Javascript runtime, so:

$> sudo apt-add-repository ppa:chris-lea/node.js
$> sudo apt-get update
$> sudo apt-get install nodejs

We can continue to use RVM to install gems:

$> rvm rubygems current

Once everything is set up, it is time to install Rails:

$> gem install rails

P.S.

Postinstall & Troubleshooting.

When we disable GNOME Terminal's "Run command as login shell", rvm unable to load as a function, so typing:

$> type rvm | head -1

outputs something like "rvm is /home/mercurial/.rvm/bin/rvm".

In order fix this, edit ~/.bashrc and add the following line in the end of file:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.

Upvotes: 3

Ryan Bigg
Ryan Bigg

Reputation: 107718

Don't use sudo to install your rails gem, because that'll switch to a different user which doesn't have access to your RVM installation. Just use gem install rails.

I would still recommend uninstalling the system Ruby.

Upvotes: 3

Paulo Henrique
Paulo Henrique

Reputation: 1025

First: It doesn't seems that you are installing it using rvm at all. When using rvm it should install or in your home or in /usr/share. This install on /usr/lib is about a normal install of ruby.

To install it on the system instead of the rvm, u should install the dev version of the ruby package, like

apt-get install ruby1.9-dev

But, if u want to isntall using rvm, as i think u wantm u should install it with

rvm install 1.9.3.

Let me know if is not your case.

Upvotes: 0

Related Questions