Installing ruby to specific directory/usb

installruby

I am trying to install ruby to a specific directory, a USB stick, so I can move the usb back and forth without having to install ruby on each machine I get to (I need ruby 2.0+). How can I do this?

I have been looking after stuff like setting RVM install directory and so forth, with no luck. The closest I found was this description telling me how to move the entire RVM install, which I don't want. I just want a simple ruby version on a usb stick.

On windows this was very easy: Run RubyInstaller, and point it to the USB. On OSx, well, that's another story.

How can I achieve this?

Best Answer

So I figured this out:

What you must do is download the ruby source, and extract it wherever. Then you have a folder named ruby-2.1.2, or something reflecting your ruby version.

Then, in terminal, cd to that directory. Then run:

./configure --prefix=/Volumes/USB_STICK_NAME/folder/to/install/into/osx_ruby
make
sudo make install

Protip: drag-n-drop the ubs-folder you want into the terminal to get the desired folder path. Much easier than writing it

That will install ruby into your usb-stick named "USB_STICK_NAME" under the folders folder/to/install/into/osx_ruby. Feel free to name it differently, but remember; The folder you select as install directory is where all the internal ruby stuff ends up, like bin, lib. I would recommend naming that folder "osx_ruby" or something similar.

Hope someone finds this useful.