Installing Ruby on Linux as a User other than root

June 17, 2010

(This article was first published on R-Chart, and kindly contributed to R-bloggers)

Ruby is best known as the language behind the rails web application framework. However, it is a very flexible general purpose language that can be used for tasks of direct interest to R Developers (parsing files, interacting with databases, processing XML or JSON, math functions, statistics, machine learning, etc).

If you do not have root access on a Linux server, you may still be able to install the ruby language and rubgems. Start by checking the version currently installed (if any):

whereis ruby

which ruby

ruby –version

Create or navigate to a temporary directory.

mkdir ~/tmp

cd ~/tmp

Get a source archive of ruby and ruby gems from RubyForge.


Uncompress and extract the downloaded source into such like $HOME/tmp.

tar -xzvf ruby-1.8.6-p110.tar.gz

Change directory to the location of extracted sources.

cd ruby-1.8.6-p110

Run configure script with –prefix option set to $HOME (avoid permissions issues). This will result in an installation of ruby in your home directory.

./configure –prefix=$HOME


make install

Add $HOME/bin to your path (in ~/.bash_profile or other startup script).

export PATH=/home/username/bin/:.:$PATH

Verify the correct version was installed:

ruby –version

Keep in mind that various subdirectories will be created by this process (bin, lib, share).

Download Gems


Set GEM_HOME to a gems directory that you have write access to. Replace /home/username with your own home directory location. Use “pwd” to get correct syntax.

export GEM_HOME=/home/username/gems

Run the ruby gems setup program.

ruby setup.rb

Depending upon your environment, you may want to set up aliases, configure your PATH or other environmental variables.

alias ruby=’~/bin/ruby’

export GEM_HOME=/home/csaternos/gems

export RUBYOPT=rubygems

To leave a comment for the author, please follow the link and comment on their blog: R-Chart. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...


Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)