Installing Ruby on Linux as a User other than root

[This article was first published on R-Chart, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.


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.


wget http://rubyforge.org/frs/download.php/25689/ruby-1.8.6-p110.tar.gz


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

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

wget http://rubyforge.org/frs/download.php/69366/rubygems-1.3.6.zip

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.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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)