Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prerequisites required for compiling Ruby 1.9.2 on Linux?

Tags:

ruby

ubuntu

I am new to Ruby and RoR. I have a clean Linode instance with an Ubuntu image, and I want to compile Ruby from source instead of using apt-get. I have googled for instructions of doing this, but after some tries I keep on getting errors regarding missing zlib and some other packages when I try to run some tutorials samples.

Can anyone please give me detailed instructions (or a link) that would teach me how to get the necessary prerequisite packages installed before I compile Ruby from source?

My intent is to compile latest stable release of Ruby, then install Rubygems and Rails. Thanks for any help in advance!!!

like image 903
Ke Sun Avatar asked Nov 20 '10 19:11

Ke Sun


3 Answers

This blog post covers the necessary packages and install process to compile ruby from source; it references Ruby 1.9.1 but it should work just fine with Ruby 1.9.2 as well. The real useful bit from this post is:

sudo apt-get -y install libc6-dev libssl-dev libmysql++-dev libsqlite3-dev make build-essential libssl-dev libreadline6-dev zlib1g-dev libyaml-dev

It looks like to me that a few of these are not essential unless you want to go on to use MySQL or SQLite, but otherwise this list of packages will get what you need to compile Ruby.

After that, I wouldn't recommend actually installing Ruby from source manually; I would use RVM (Ruby Version Manager) so you can install any version of Ruby you wish, now and later. RVM compiles the different versions of Ruby by downloading and compiling the source code, and will also install Rubygems for you.

Once you have installed rvm, you can use rvm requirements to get the current list of required packages.

like image 176
wuputah Avatar answered Oct 21 '22 14:10

wuputah


You can use apt-get install all the build dependencies for any package. Enable your source repository and then run.

sudo apt-get build-dep ruby1.9 rails

This will install all the packages you will need to compile the source for these two packages. Then you can go get the latest source, and follow the instructions.

N.B.: Packages names may be wrong, depends on which version of Ubuntu you're using.

like image 33
EmFi Avatar answered Oct 21 '22 13:10

EmFi


I HIGHLY recommend using 'RVM' to install all your rubies, especially if you're doing it just for your own use. RVM will do all the compilation for you, puts everything in ~/.rvm including the gems, and makes it easy to install multiple versions of Ruby and gems for testing.

Installation and using gems will get you running. RVM's Gemsets are powerful, and RVM's ruby command makes it nice for performing some action across all the installed Rubies RVM manages.

RVM also supports system-wide installations offering RVM's flexibility if you need it, but it's a bit more complicated and is unnecessary if you're on a single-user machine.

like image 33
the Tin Man Avatar answered Oct 21 '22 12:10

the Tin Man