Wednesday, October 28, 2015

Install Ruby from source code

You can install ruby with following steps:
sudo apt-get update
sudo apt-get install build-essential libssl-dev libyaml-dev libreadline-dev openssl curl git-core zlib1g-dev bison libxml2-dev libxslt1-dev libcurl4-openssl-dev nodejs libsqlite3-dev sqlite3
Create a temporary folder for the Ruby source files:
mkdir ~/ruby
Move to the new folder:
cd ~/ruby
Download the latest stable Ruby source code. (https://www.ruby-lang.org/en/downloads/)
If 2.1 then
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.1.tar.gz
If 2.2 then
wget http://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.0.tar.gz
Decompress the downloaded file:
If 2.1 then
tar -xzf ruby-2.1.1.tar.gz
If 2.2 then
tar -xzf ruby-2.2.0.tar.gz
Select the extracted directory:
cd ruby-2.2.0
Run the configure script. This will take some time as it checks for dependencies and creates a new Makefile, which will contain steps that need to be taken to compile the code:
./configure
Run the make utility which will use the Makefile to build the executable program. This step can take a bit longer:
make
Now, run the same command with the install parameter. It will try to copy the compiled binaries to the /usr/local/bin folder. This step requires root access to write to this directory. It will also take a bit of time:
sudo make install
Ruby should now be installed on the system. We can check it with the following command, which should print the Ruby version:
ruby -v
Finally, we can delete the temporary folder:
rm -rf ~/ruby
Reactions:

0 comments:

Post a Comment