Build Ruby, RubyGems and Ruby on Rails in the new Snow Leopard

Original author: Dan Benjamin
  • Transfer
These are instructions for building and installing the 64-bit version of Ruby, Rubygems, and Ruby on Rails on the new Mac OS X 10.6 Snow Leopard.

The advantages of Ruby's own assembly are /usr/localdescribed here and here .



Requirements

Before you begin, make sure that you have all of the following:
  1. Mac OS X 10.6 Snow Leopard
  2. Latest version of Xcode Tools (from Snow Leopard or from Apple - version 10.5 is not suitable )
  3. Understanding Unix basics and terminal skills.


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

Step 1: Setting the PATH Environment Variable

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

The first thing we will do is set the PATH environment variable. It determines where the system searches for the commands that we enter. You will need to supplement it so that the jokes that we are going to install are visible to the system and the command line. Using any text editor, create and edit a file in your home folder .profile(pay attention to the "." At the beginning)

If you use Textmate , you must have the mate shell command installed , you can create and edit the file like this:

mate ~/.profile

Add the following to the end of the file line:

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

Save and close the file, then run the following command so that the changes are loaded into the current shell session.

source ~/.profile

To make sure everything went as it should, enter the following command:

echo $PATH

You should see a line /usr/local/binat the beginning of the response.

Step 2: Download

We will create a folder in which we put the files that we are going to download and install. If you want, you can delete this folder at the end, but you can leave it there - it will make it easier to reinstall or delete if you need to.

Make a folder: Download Ruby and Rubygems:

mkdir ~/src
cd ~/src




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: Assembly and Installation

First Ruby: To make sure everything is installed correctly and where you need it, type: You should see. If so, then now you have a super-fast 64-bit Ruby and it is completely ready to work. If you see something else, then most likely you have set PATH incorrectly. Check if you did everything right in the first step and try again. Build and install Rubygems: Install Rails. If you use MySQL, you can still install the MySQL gem. To do this, you need to know where MySQL is installed. Usually it is . Then the installation of the gem will look something like this: Congratulations, now you have your own assemblies of fresh versions of Ruby, Rubygems and Rails installed, which do not conflict with the system. Hurrah.

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 ..




which ruby



/usr/local/bin/ruby




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




sudo gem install rails

/usr/local/mysql

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


Also popular now: