Installing Rails on Ubuntu 12.10
Installing Rails on Ubuntu 12.10
Join the DZone community and get the full member experience.Join For Free
Do you need to strengthen the security of the mobile apps you build? Discover more than 50 secure mobile development coding practices to make your apps more secure.
Installing Ruby and Rails on Ubuntu 12.10 can throw up some errors. I’ve found a method that worked, and wrote a few notes about it.
This is a fresh copy of a post I wrote some time ago. It does still work as described. However, I am close to finishing a book on Rails 4.0. It will be published by SitePoint, so keep an eye out for it there. It should be available within the next couple of months. There is a much more comprehensive description of how to install Rails for Ubuntu in it.
I chose to go with RVM because that it was I used with previous versions of Ubuntu. All this work is done on the terminal. To install Ruby and Rails, you need to make sure that you have curl installed:
sudo apt-get install curl
While you are at it, you might as well install Git:
sudo apt-get install git-core
Next, we can install RVM:
curl -L get.rvm.io | bash -s stable
Installing the Dependencies for Ubuntu
Then, and this bit is critical, do:
You’ll get a list of dependencies that MUST be installed for things to work properly. The list will look something like this:
Additional Dependencies: # For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following: ruby: /usr/bin/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
You have to install the dependencies. Bad things will happen if you don’t.
Well, not really bad things: Ruby/Rails just won’t work.
Next, you need to make sure that RVM is being loaded as a function. And this might present a problem. The usual method is to get on Terminal and do:
Re-start Terminal, and then do:
type rvm | head -n 1
You should get:
RVM is a function as a reply. If you do, great. If not, you’ll need to follow the instructions on the RVM web site here. What you need to do, is get Gnome-Terminal to
Run command as login shell.
Here is how it’s explained on the RVM web site:
“By default, gnome-terminal runs Bash as usual, as a non-login shell, therefore skipping /etc/profile* and executing only the user’s ~/.bashrc. This means that RVM doesn’t load and you get the infamous ‘RVM is not a function’ message.”
So when you have done that, and run
type rvm | head -n 1 again, you should get the
RVM is a function response.
Things should become a lot easier now. To install Ruby, we just do:rvm install 1.9.3
RVM will go ahead and download and install Ruby version 1.9.3. Next, make sure that your system is using the newly installed Ruby:rvm use 1.9.3 --default
We should be good to install Rails now:gem install rails
The MySQL Gem
You can install MySQL through Software Centre these days. But when you do, make sure you also install
libmysqlclient-dev because the mysql2 gem needs the header files. Otherwise, you will see all kinds of weird error messages when trying to install the gem.
I am now able to build Rails apps on my Ubuntu 12.10 installation. I’ll update this post if I find anything else that needs a tweak to get it working.
Published at DZone with permission of Andy Hawthorne , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.