SmeagolGollum
SmeagolGollum

Reputation: 107

How to install ruby on linux in a specific folder

I try to install ruby and rails to start to learn ruby on rails.

I work on Windows. After many search and tries, I gave up and installed a fresh ubuntu 14 x64 in a VirtualBox.

I installed ruby with apt-get, but its files get spread all over the file system (/bin, /var...). So, I have to use always sudo and search all over the place when installing gems.

I would like, just like in windows, find a ruby tar.gz which I can decompress in a folder of mine, with all files at the same place, where I have the "control" over the files, and I can watch easily what it's hapenning while installing gems, rails, etc...

The problem : I cannot find any tar.gz (or similar archive) of ruby for linux which I simply can uncompress in a folder and work with it (I can manage the $path). The only one I can find is for Windows !

Thanks !

Upvotes: 1

Views: 5584

Answers (2)

SmeagolGollum
SmeagolGollum

Reputation: 107

Thank you Max for your response.

In case someone else tries to compile ruby on a fresh new ubuntu, this is what I had to do to build and use it with success :

Install missing dependencies :

get the latest "Stable Snapshot" from https://ftp.ruby-lang.org/pub/ruby/stable-snapshot.tar.gz and not the "Current stable"
sudo apt-get install libffi-dev
sudo apt-get install zlibc zlib1g zlib1g-dev
sudo apt-get install openssl
sudo apt-get install libssl0.9.8 [[[   first, find the latest version with : apt-cache search libssl | grep SSL  ]]]
sudo apt-get install ca-certificates
sudo apt-get install libssl-dev
sudo apt-get install libreadline-dev

Then :

  1. Edit downloaded file tools/rbinstall.rb, goto line 714 and correct the typo : change "rescue LoadErroe" to "rescue LoadError" (not corrected in date of 20 March 2015).
  2. Run Max's instructions above
  3. Don't move the ruby destination folder declared with "--prefix" (even if you try to correct the shells in ruby/bin)

Finally, for using rails :

sudo apt-get install libsqlite3-dev
sudo apt-get install nodejs     ==> inorder to have a js runtime

Upvotes: 1

Max
Max

Reputation: 22375

It sounds like what you want is Ruby's source code. Go to https://www.ruby-lang.org/en/downloads/ and look under "Compiling Ruby - Source Code". That's where you'll find the .tar.gz files you want. You'll need to compile and install it before you can actually use it. Installing normally copies files "all over the file system", but you can force it to install to a specific folder by passing the --prefix option to the ./configure script.

$ tar -xf ruby-2.2.1.tar.gz
$ cd ruby-2.2.1
$ ./configure --prefix=/my/ruby/dir
$ make && make install

You may need to install some dev packages in order to get it to compile, but any compilation errors should make it clear what you need.

These instructions are also described here.

Upvotes: 3

Related Questions