Ruby

Installing Ruby

UPDATE - on Mac or Linux

see this page - http://cbednarski.com/articles/installing-ruby/


Installing Ruby, RubyGems, and Rails on Snow Leopard

http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard

These are instructions for compiling and installing 64-bit Ruby, Rubygems, and Ruby on Rails on Mac OS X 10.6, Snow Leopard.

The benefits of manually building a copy of Ruby in /usr/local are detailed here and here.

Prerequisites

Before following these instructions, you will need:

  1. Mac OS X 10.6 Snow Leopard
  2. The latest Xcode Tools (from the Snow Leopard DVD or downloaded from Apple — the 10.5 version won’t work)
  3. Confidence running UNIX commands using the Terminal

If you want to learn more about UNIX and the command line, check out my PeepCode screencast on this topic.

Step 1: Set the PATH

Launch Terminal.app from the /Applications/Utilities folder.

The first thing we’ll do is set your shell’s PATH variable. The PATH variable determines where your system searches for command-line programs. You’ll need to set it so that it can find the new apps you’re about to install. Using the editor of your choice, create and edit a file in your home directory named .profile (note the “.” preceding the filename).

If you’re using TextMate like you should be and have installed the UNIX mate command, then you can create and start editing the file like this:

mate ~/.profile

To the end of this file, add the following line:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

Close and save the file and run this command to load the new setting into your current shell:

source ~/.profile

To verify that you’ve updated your path, enter the following command:

echo $PATH

You should see /usr/local/bin at the beginning of the line returned by the system.

Step 2: Download

We’re going to create a folder to contain the files we’re about to download and compile. If you want, you can delete this folder when you’re done, but keeping it around makes it easier to re-install (or uninstall) these apps later.

Make the new folder:

mkdir ~/src
cd ~/src

Download Ruby and Rubygems:

curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p174.tar.gz
curl -O http://files.rubyforge.vm.bytemark.co.uk/rubygems/rubygems-1.3.5.tgz

Step 3: Compile and Install

First, Ruby:

tar xzvf ruby-1.8.7-p174.tar.gz
cd ruby-1.8.7-p174
./configure --enable-shared --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1
make
sudo make install
cd ..

To verify that Ruby is installed and in your path, just type:

which ruby

You should see:

/usr/local/bin/ruby

If you do, this means you now have a super-fast, 64-bit version of Ruby ready to go. If you saw something different, you haven’t set your path correctly. Go back and try again.

Compile and install RubyGems:

tar xzvf rubygems-1.3.5.tgz
cd rubygems-1.3.5
sudo /usr/local/bin/ruby setup.rb
cd ..

Install Rails:

sudo gem install rails

If you use MySQL, you can now install the MySQL gem. You’ll need to know the location of your MySQL installation, which is typically /usr/local/mysql. Install the gem like this:

sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql

Congratulations, you now have a custom-built Ruby, RubyGems, and Rails configuration.


On Linux

UPDATE - see this page - http://cbednarski.com/articles/installing-ruby/

https://github.com/joequery/Rails-Template/wiki/Installing-Ruby-via-RVM-on-Ubuntu-Lucid-10.04

This will be a system-wide install using RVM.

Install system ruby

    $ sudo apt-get install ruby

Install RVM

    $ sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

Install a bunch of packages needed to get ruby 1.9.2+ to play nicely on Lucid under RVM

    $ sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev autoconf libxslt-dev

Verify that RVM installed correctly.

    $ which rvm

/usr/local/rvm/bin/rvm If `which rvm` does not return a response, try logging out of your server and logging back in.

According to the RVM documentation, it's extremely important that you do not use sudo for anything related to rvm with the exception of the initial install and upgrading RVM itself. Rvm comes with a sudo wrapper that preserves certain environment variables that rvm needs to run properly. This wrapper is called rvmsudo, and you use it just like you would sudo.

Link zlib with rvm

    $ rvmsudo rvm pkg install zlib

Download and install new ruby via rvm. WARNING This will take an ungodly amount of time.

    $ rvmsudo rvm install 1.9.3

Users that need access to RVM rubies will need to be added to the rvm group.

    $ sudo usermod -a -G rvm USERNAME

NOTE: If you're adjusting the groups of the currently logged in user, you'll need to log out and log back in before changes go into effect.

Make 1.9.3 the default ruby

    $ rvm use 1.9.3 --default

Verify the correct version of ruby is being used

    $ ruby --version

ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]


On Windows

PmWiki

pmwiki.org

Blix theme adapted by David Gilbert, powered by PmWiki