Update for Leopard Users: The Ruby on Rails for Leopard installation instructions can be found here.
This article is a major update to the older (but tried-and-true) post, Building Ruby, Rails, LightTPD, and MySQL on Tiger. Both Ruby, Rails, and their underlying infrastructure have come a long way in recent months, and this article will get you to a leaner, meaner Rails install in less time using fewer steps.
This article is updated on a regular basis as new versions of the software are released.
What follows are instructions for building and installing the following applications on Mac OS X 10.4 (Tiger) along with their supportive software. I’ve been told that these steps work just fine on Mac OS X 10.3 (Panther) as well, but I haven’t verified this myself, and your mileage may vary.
Compiling and installing these tools this way is well worth the effort, as the end result delivers an easy-to-upgrade, system-independent, stand-alone development platform that is impervious to potential problems that can be caused by system updates, operating system upgrades, etc.
By rolling our own from source this way, we also have full control over our environment. We know what’s installed and where, what version we’ve used, where it came from, and there’s no dependence on an external ports system and the breakage or issues that come from relying on others to manage our software.
These issues and additional background information about why one might roll their own tools in this fashion are detailed in the article, Using /usr/local/, which could be considered a prerequisite for this task.
About (Not) Removing Old Versions
One of the great things about building these particular apps from source like this is that we don’t need to worry about removing older versions. When we build the new ones, they will replace the older versions as needed, and your system will be up to date with just the latest, greatest software.
The Concept
Basically, what we’re going to do here is download a bunch of open-source tools (some of which rely upon each other to work), configure them, compile them, and install them, one by one, until we have everything we need for a Mac OS X machine to run Ruby on Rails.
What’s Needed
A few things are needed to get this going:
- Mac OS X 10.4 (and maybe 10.3)
- Xcode 2.4 or newer (this compiles the apps for us)
- Willingness to type commands into the Terminal application exactly as they appear here (cut-n-paste works too)
- A tasty beverage to enjoy while things compile
Note: Xcode is not installed by default on new Macs, but can be found on the Mac OS X install DVD/CD, or downloaded from Apple’s Developer Connection free of charge.
Another Note: These instructions assume that you’re using bash, the default UNIX shell for Mac OS X 10.4. If you don’t know what this means and haven’t done anything very special to change this, you’re fine. If you’ve taken specific steps to change the default shell to something other than bash (like tcsh for example), you’ll need to be figure out the right files and syntax to use when setting paths and environment variables, or switch back to bash. Sorry about that.
A Quick Warning
While it’s unlikely anything we do here might do any kind of damage to the system, it’s good advice to have a current backup of everything, just in case. I don’t take any responsibility for anything that results from following these instructions (good or bad). You’re following these instructions at your own risk.
A Note about sudo
We’ll be using the command sudo quite a bit, and lots of people wonder what it does. Put simply, the sudo command allows a user (in this case, you) to execute a command as the superuser, allowing you to become the omnipotent master of your computer one command at a time.
With great power comes great responsibility, so Mac OS X may prompt you for your password prior to executing your command. It may do this only once, or several times throughout this process. Just re-enter your password as needed.
A Terminal Situation
Open the Terminal application. It can be found in the /Applications/Utilities folder.
Each of the lines below appearing in monospaced type should be entered into Terminal, and be followed by the Return key. But everybody knew that already.
Paths
Do not skip this step! Most everything else will fail if you do.
Mac OS X, like other UNIX systems, uses something called a path to determine where it should look for applications on the command line (that is, when you’re using the Terminal app). The path is actually an environment variable, set by a special file that’s automatically executed when you open a new Terminal window.
We need to make sure that our path is set to look for files in /usr/local (the place where we’ll be installing the tools) before looking anywhere else. This is important.
To see if the path has been set properly, we can check the contents of the .bash_login file (the special file hidden in our home folder) for a PATH line using a text editor. TextMate, TextWrangler, BBEdit, and vi are all perfectly good options. To open the file with TextMate, for example, we can type:
mate ~/.bash_login
This will open the file if it already exists, or open a blank file if it doesn’t. Add the following line at the very end of the file:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
Now save and close the file.
It doesn’t matter how many other lines there are in the file, or what they say or do. Just make sure that this line comes last and you should be fine.
To make sure the changes are picked up correctly, we now need to execute the file with the following command:
. ~/.bash_login
It’s likely there will be no response from the shell here, just the prompt, but that’s OK, the changes have been picked up and we’re ready to move on.
You can also close your Terminal and open a new one instead if you’d like.
Geek Note: You may have noticed that I’ve added MySQL to the path in the line above. That’s because most users will be installing MySQL later in this tutorial. If you’re the type to want to use something like SQLite or PostGreSQL as your database instead of MySQL, you can feel free to omit the /usr/local/mysql/bin: bit from the line above, and replace it with the path to the database of your choice. If this note doesn’t make sense to you, even if you don’t plan to install MySQL later, just keep on going … the extra bit in the path statement won’t affect you at all.
Setting Up
I like to create a folder to contain all of the downloaded files and their respective build folders. I tend to keep this folder around indefinitely. Source code doesn’t take up much space, and it’s useful to refer back to later to remind yourself of previous installation details or techniques, installed versions, for a fast install at a later time, or in case you want to uninstall something.
For these examples, we’ll create a folder called src in the /usr/local section of the filesystem, and change directories into that folder. It will be our workspace for everything we do here:
sudo mkdir -p /usr/local/src sudo chgrp admin /usr/local/src sudo chmod -R 775 /usr/local/src cd /usr/local/src
You’ll download and compile everything in this new folder.
Ruby
Now we’re ready to start the real work. Just type (or cut-n-paste) each one of the following lines into Terminal, one by one. When one line finishes (some will take a while and dump a lot of information to the screen), enter the next one.
As mentioned above, the first time you run the sudo command (and possible again later), you may be prompted for a password. Just enter your regular password here, and the process will continue.
We’ll start off with Ruby, but before we can compile Ruby itself, we’ll build a supportive application called readline. The commands below handle downloading, unzipping, configuring, compiling, and finally installing the code. This “pattern” will become more familiar as you move through the install step by step.
curl -O ftp://ftp.gnu.org/gnu/readline/readline-5.1.tar.gz tar xzvf readline-5.1.tar.gz cd readline-5.1 ./configure --prefix=/usr/local make sudo make install cd ..
If you get an error like the one below after typing the configure command:
checking whether make sets $(MAKE)... no checking for gcc... no checking for cc... no checking for cc... no checking for cl... no configure: error: no acceptable C compiler found in $PATH
This means that you did not follow the instructions and don’t have Xcode installed.
If you saw lots of text fly by but didn’t get that error, it means that everything went well, and we can move on to building and installing Ruby itself.
curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.gz tar xzvf ruby-1.8.6.tar.gz cd ruby-1.8.6 ./configure --prefix=/usr/local --enable-pthread --with-readline-dir=/usr/local --enable-shared make sudo make install sudo make install-doc cd ..
If you saw lots of text fly by but didn’t get that error, it means that we should now have a brand new Ruby installed.
We can verify this (as well as a correct path setting) by typing the following command:
ruby -v
You should see something like this:
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1]
Don’t worry about the text in the parenthesis or brackets, those just provide detail about your system architecture which isn’t important here. What is important is that you see ruby 1.8.6. This means you’ve got the new version of Ruby installed and in your path, and you’re good to go.
If you see something like this:
ruby 1.8.2 (2004-12-25)
Then either your install failed, or you didn’t correctly set your path in the beginning (maybe you didn’t reload your .bash_login script or restart Terminal). Go back and check your work.
RubyGems
RubyGems is a handy command-line tool for managing the installation of Ruby packages, like Rails and Mongrel.
curl -O http://files.rubyforge.mmmultiworks.com/rubygems/rubygems-0.9.2.tgz tar xzvf rubygems-0.9.2.tgz cd rubygems-0.9.2 sudo /usr/local/bin/ruby setup.rb cd ..
Ruby on Rails
With RubyGems installed, Rails is a simple, one-line install:
sudo gem install rails --include-dependencies
If you see an error message like this:
/usr/local/bin/gem:3:in `require': No such file to load -- rubygems (LoadError) from /usr/local/bin/gem:3
It means you didn’t set your path as instructed in the very first step. Go back to the beginning and run that step again, then retry this step.
Mongrel
Mongrel is a fast, stand-alone HTTP library and server for Ruby. It allows you to run your Rails applications without having to compile or use other applications (like FastCGI, SCGI, LightTPD, or Apache).
Even better, Mongrel is also a gem. Type this command:
sudo gem install mongrel --include-dependencies
You’ll be prompted to select the appropriate gem for your platform, and you’ll be shown a list something like this one:
Select which gem to install for your platform 1. mongrel 1.0.1 (ruby) 2. mongrel 1.0.1 (mswin32) 3. mongrel 1.0 (mswin32) 4. mongrel 1.0 (ruby) 5. Skip this gem 6. Cancel installation
Although version numbers may be different, you should always select the one closest to the top of the list that ends with “(ruby)” … this is usually the first option. Just type the number and press enter.
Subversion (Optional)
Subversion is an open-source version control system. It remembers every change ever made to the files and directories in your projects. This allows you to recover older versions of your data, or examine the history of how your data changed. You can read more about Subversion (svn) in the online Subversion book.
While it’s not mandatory to have svn running in order to use Rails, it’s highly recommended. It’s used by the Rails team for distribution management, by most web hosts for deployment (via Capistrano), and by most Rails developers to manage their code.
curl -O http://subversion.tigris.org/downloads/subversion-1.4.3.tar.gz curl -O http://subversion.tigris.org/downloads/subversion-deps-1.4.3.tar.gz tar xzvf subversion-1.4.3.tar.gz tar xzvf subversion-deps-1.4.3.tar.gz cd subversion-1.4.3 ./configure --prefix=/usr/local --with-openssl --with-ssl --with-zlib make sudo make install cd ..
Capistrano
Capistrano is a utility which may be used to automate the deployment of your Rails applications. Many Rails applications and webhosts require it, and while this is technically an optional step, it’s simple, fast, and highly recommended. You can get the latest version of this gem like this:
sudo gem install capistrano --include-dependencies
I also recommend installing termios, a gem that’s a wrapper for the UNIX termios command, which will prevent passwords you enter in Capistrano from being displayed in your Terminal for all to see.
sudo gem install termios --include-dependencies
Technically, you could stop right here. But most Rails applications need a database …
MySQL
While it’s possible to compile and install MySQL ourselves, using the Mac OS X MySQL package is actually advantageous. Not only is the package-installer much faster and easier, but it includes a handy startup item and a preference panel, and the binary is tuned by the MySQL team for Mac OS X.
Even better, the package installs MySQL right into the /usr/local/ folder, just like it should!
The install still requires a few steps:
- Download the MySQL 5.0 package for OS X PPC or the MySQL 5.0 package for OS X Intel
- Double-click the drive image to mount it
- Locate the MySQL installer (a file named something like
mysql-5.0.37-osx10.4-i686.pkg) and run it, authenticating as needed - Double-click
MySQLStartupItem.pkg, authenticate, and let it install - Double-click
MySQL.prefPaneand install it, deciding whether to make it available to just the current user, or for all system users
Once the install is complete, start the MySQL server using the newly-installed control panel.
Note: MySQL installs with a default user of root using no password. If you care about the privacy of your data or computer, please read this page about MySQL usernames and passwords and set a good one.
MySQL Native Bindings Gem (Optional)
This step is an optional one, but the performance gains seem to make it worth the extra step.
We start with a command to install the gem:
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
Just like the Mongrel install, you might see a prompt asking you which gem to install:
Select which gem to install for your platform 1. mysql 2.7.3 (mswin32) 2. mysql 2.7.1 (mswin32) 3. mysql 2.7 (ruby) 4. mysql 2.6 (ruby) 5. Skip this gem 6. Cancel installation
Again, just like the Mongrel install, we’ll want to pick the option closest to the top that ends in “(ruby)”. In the example above, we’d want to select option 3.
You’ll see some text scroll by and when it’s done, you’ll have built native MySQL bindings, which should help make database operations a bit faster.
Fix MySQL
There’s an issue with the current version of MySQL and the latest Ruby. Fortunately, this is easily fixed with the following command in Terminal:
sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle
You may be prompted to re-enter your password when you run it.
We’re Done
Congratulations, you now have a custom-built, properly located installation of Ruby, Ruby on Rails, MySQL, Mongrel, and Capistrano!
If you’re new to Rails and just want to create a sample app to see this all working, try this:
rails testapp cd testapp script/server
This will create a basic Rails app in a folder called testapp in your current folder (probably /usr/local/src if you’re doing this where the last step left off).
If all goes well, you’ll get some output that looks like this:
=> Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... ** Rails loaded. ** Loading any Rails specific GemPlugins ** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart). ** Rails signals registered. HUP => reload (without restart). It might not work well. ** Mongrel available at 0.0.0.0:3000 ** Use CTRL-C to stop.
You can now check out your new app by clicking or pasting this link in your browser of choice: http://localhost:3000
What Else?
To do any real work with your new app, you’ll want to create a database for it. The Rails convention is that the database will take the same name as the name you specified when the app was created (in this case, “testapp”).
You’ll need to first start up MySQL, and then create a database. While you can start MySQL using the control panel you installed earlier, it can also be started using the command line:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
You won’t have to run this command again, because the startup item you installed for MySQL will make sure it’s running the next time you boot your Mac. With MySQL running, you can create a new database for the test application:
mysqladmin -uroot create testapp_development
If you created a password for MySQL, you’ll need to add the -p option to the command above and you’ll be prompted for your password.
The rest is up to you. Good luck, and have fun with Rails!
Commenting is not available in this weblog entry.






Ken A.
29 December 2007 at 8:14 pm
I’m not even a Mac user ... what a great tutorial! Congrats :-)
Erics
31 December 2007 at 8:39 am
Hi, any word when the updated version for Leopard will be ready?
Keith Veleba
31 December 2007 at 12:41 pm
Working through this tutorial - I’ve built and installed everything here, except Subversion is saying it requires Berkeley DB. Did I miss a step? This is on a fresh Tiger install with everything up to date.
Thanks in advance,
Keith Veleba
Keith Veleba
01 January 2008 at 2:04 pm
Please disregard, solved my problem by reading another of your articles. Thanks for the great resource, and Happy New Year!
Mel
02 January 2008 at 11:48 am
What about using Ruby 1.9 instead of 1.8?
Dave
02 January 2008 at 2:51 pm
I did everything right and kept getting…
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)
when i tried installing the MYSQL into my computer. You should look into this because i literally installed this stuff 4 times and it kept giving me the same error message.
Ian Schaefer
02 January 2008 at 11:42 pm
Very nice tutorial. I’ve never _enjoy_ unix installs, but this one was close.
One small problem: I successfully installed but got an error from ‘testapp’. Turns out the version of Rails you link to requires version 0.9.4 of RubyGems; but your link to it (RubyGems) is pointing to version 0.9.2.
I tried to update using ‘gem update—system’ but got a permissions error, so I instead re-ran ‘curl’ substituting ‘0.9.4’ for ‘0.9.2’. That did the trick.
Thanks for your great work.
Tony
03 January 2008 at 12:41 pm
@Dave:
/tmp/mysql.sock is the default location where mysql is looking for its socket file, but it’s often somewhere else, depending on how you’ve installed it. Following this guide, it’s probably somewhere in /usr/local/
You should create a symbolic link from /tmp/mysql.sock to where-ever the file actually is.
sudo ln -s /actual_location/mysqld.sock /tmp/mysql.sock
Florian
04 January 2008 at 9:13 am
Hej! I have problems with the bash_login. The line “mate -/.bash_login” does not work for me, instead I write “mate .bash_login”. I then type “. .bash_login” and when opening the file, the code is still there; I close the terminal window and open a new one, and the code is still in the file but when I have installed ruby, the file is empty and “ruby -v” says “ruby 1.8.2 (2004-12-25)”. What Am I doing wrong? Please, if anyone could help me.
Florian
04 January 2008 at 10:15 am
my fault… I saw a hyphen instead of a tilde.
r c johnston
04 January 2008 at 3:33 pm
After trying to install Gems it tells me that “No library stubs found”.
Then I run:“sudo gem install rails—include-dependencies” and get “sudo: gem: command not found”.
Suggestions, hints?
tia
Craig Vidler | Weblog » links for 2008-01-05
05 January 2008 at 1:18 pm
[...] Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X at Hivelogic Installing Ruby on Rails etc on OS X 10.4 Tiger (tags: osx mysql ruby rails svn) [...]
GraphicEngineer
05 January 2008 at 11:38 pm
Excellent tutorial - thanks! Still relevant as of January ‘08!
Note: users may need to update their RubyGems version from 0.9.2 to the latest (1.0.1 at the time of this comment.) The RubyGems update is needed to get the script/server running and is easy with the command: sudo gem update—system
RJ
06 January 2008 at 4:23 pm
I was able to get everything installed okay. The only problem is that the default database is now SQLite3. So, if you want to create apps with the above instructions using MySQL, you’ll have to start it using “rails -d mysql myApp”. Else, install SQLite3 and use it. These instructions are easy to use and very much appreciated. Thanks!
r.connor
06 January 2008 at 11:45 pm
i’m having the same problem at tia
dakan
07 January 2008 at 5:17 pm
All went well for me except with Rails. I got this error? Any hints?
$ sudo gem install rails—include-dependencies
Bulk updating Gem source index for: http://gems.rubyforge.org
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find rails (> 0) in any repository
What should I do?
dan
08 January 2008 at 12:32 pm
@dakan - I had the same issue. For me things went better when I changed my .bash_login so that the PATH stuff was the last thing.
notBanksy
09 January 2008 at 5:36 am
Have noticed a small error on this tutorial. According to apple http://developer.apple.com/tools/xcode/update.html Xcode 2.4 will not run on panther…
Anyone got any tutorials for rails on panther?
Naresh
12 January 2008 at 1:15 am
@dakan - I had the same problem. I’d initially put the PATH suggested in my .bash_profile file and it worked all the way until the rails installation.
I got rid of my .bash_profile file and shifted the PATH and other stuff that I had in it into .bash_login as suggested.
Zak
13 January 2008 at 11:30 pm
OK, I am a loser. Please help. I set path correctly
zak:~ zak$ echo $PATH
/usr/local/mysql/bin:/bin:/sbin:/usr/bin:/usr/sbin
zak:~ zak$
and the ruby install went well:
. .
zak:/usr/local/src/ruby-1.8.6 zak$ sudo make install
Password:
./miniruby ./instruby.rb—dest-dir=””—extout=”.ext”—make=“make”—mflags=””—make-flags=””—installed-list .installed.list—mantype=“doc”
installing binary commands
installing command scripts
installing library scripts
installing headers
installing manpages
installing extension objects
installing extension scripts
zak:/usr/local/src/ruby-1.8.6 zak$ ruby -v
——> AND Yet…
ruby 1.8.2 (2004-12-25) [universal-darwin8.0]
Zak
13 January 2008 at 11:39 pm
Found bug. I had a .bash_profile which was messing with my $PATH
r.connor
16 January 2008 at 5:41 am
I’m with Dave. Stuck on mysql.sock missing from system. Did a sudo find / -name ‘mysql.sock’ and got nothing. : (
David Sletten
17 January 2008 at 11:35 pm
As of 17 Jan. 2008 the MySQL package link above (http://mysql.he.net/Downloads/MySQL-5.0/mysql-5.0.37-osx10.4-powerpc.dmg) appears to be dead.
This looks like a good substitute:
http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg
Latest version is 5.0.45.
johnmci
18 January 2008 at 12:06 am
jm-mbp:ruby-1.8.6 john$ ./configure—prefix=/usr/local—enable-pthread—with-readline-dir=/usr/local—enable-shared
...
ruby: [BUG] Segmentation fault
ruby 1.8.6 (2007-03-13) [i686-darwin9.1.0]
make: *** [.rbconfig.time] Abort trap
Everything went well until I got to the configure command to make ruby.
I’m running Leopard 15.1. Is there a later release than 1.86?
If so, how do I recover from this?
Thank you.
Obvious newbie
KL Tah
18 January 2008 at 9:48 am
thanks for the write-up—this was definitely helpful to getting rails up and running for me.
the process went pretty smooth for the most part but some comments are in order:
1. I’m with Ian on the gem version. running “sudo gem update—system” will get the latest version installed.
2. I got the following error starting up rails the first time round:
[Admins-Computer 7] ktah > rails testapp
/usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:251:in `report_activate_error’: Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:188:in `activate’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:66:in `active_gem_with_options’
from /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:50:in `gem’
from /usr/local/bin/rails:18
but it went away after re-running the gem for rails install.
3. installing mysql from binary is actually a great idea. no hitches there. I actually tried installing from source initially, but gave up after not being able to solve problems related to setting the root password.
4. as of a yesterday, ruby 1.9 is bugged. according to the forums, its in the process of being fixed (if its not already at time of this writing).
dc
18 January 2008 at 3:55 pm
I’m with Dave & r.conner/.
Stuck on mysql.sock missing from system. Did a sudo find / -name ‘mysql.sock’ and got nothing. : (
Installation works a treat, updated gems to 0.9.4 & basic rails works but no db?
Dc
18 January 2008 at 4:03 pm
In addition to my above this is the failure:
Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
any help would be much appreciated.
Martin
19 January 2008 at 10:04 am
dakan
Jan 7th, 2008 at 5:17 pm
All went well for me except with Rails. I got this error? Any hints?
$ sudo gem install rails –include-dependencies
Bulk updating Gem source index for: http://gems.rubyforge.org
ERROR: While executing gem … (Gem::GemNotFoundException)
Could not find rails (> 0) in any repository
What should I do?
dakan, and everyone else having this problem, I had this problem, and it seems to be a bug, for some strange reason it always fails on the first attempt, just run the command again, and it should work, btw I’ve had this same problem several times on different machines and different net connections.
Jon
19 January 2008 at 4:46 pm
I completed everything the went to do rails testapp and I got the “command not found”. Not sure why…help.
Jon
19 January 2008 at 6:55 pm
got it…now what?! I don’t get it!
nathan miller
19 January 2008 at 7:54 pm
Amazing walk-through. Thanks!
Tyson
21 January 2008 at 12:13 am
Thanks, you rock!
shecky
22 January 2008 at 2:04 pm
I am an absolute newbie at all things Ruby, Rails, Terminal, etc. That said, no problems or errors until I got to the ‘We’re Done’ bit:
rails testapp
... to which Terminal says,”-bash: rails: command not found”
Also, at http://localhost:3000/ I get:
“Status: 500 Internal Server Error Content-Type: text/html
Application error (Rails)”
Any guidance is much appreciated.
Dan
25 January 2008 at 12:13 pm
Very good tutorial, I am very happy that every thing which I did went very well…Good work….
Put Together Quickly » Installing Ruby on Ra
25 January 2008 at 9:34 pm
[...] don’t think there are too many people who hasn’t come across either of Dan Benjamin’s guides when looking to install Ruby on Rails on a Mac. They are [...]
Simon Blackman
27 January 2008 at 7:50 pm
Thank you so much, I’ve been going round and round for day trying to get ruby to work, followed your instructions and boom! it works fine!
thanks again!!
New to Ruby | sun
28 January 2008 at 6:55 pm
[...] NetBeans 6. My previous attempt with RoR was about 9 month ago and remember having to do a lot of curls and makes to get everything configured. Getting started with NetBeans has been very easy, since there is a [...]
Billy P.
31 January 2008 at 8:55 pm
I was unable to get this tutorial to work for me until I used:
rails -d mysql testapp
otherwise, the system looked for sqlite3.
kwo
01 February 2008 at 1:25 pm
Great information.
Two notes…
1. Installing the Rails gem with the—include-dependencies option didn’t work for me (iTerm 0.9.5 on OS X 10.4). I tried updating RubyGems and deleting the source_cache, but couldn’t get past the “Could not find rails (> 0) in any repository” error. Finally tried it without—include-dependencies and it worked (although I had to manually approve each dependency).
2. Setting the PATH in .bash_login didn’t work for me. I don’t know if iTerm is doing something different than Terminal, but I wound up needing to set the PATH in .bash_profile.
Much thanks for the excellent info.
Chris C.
02 February 2008 at 2:58 am
This was great! I’m a complete novice and had no problems until the very end in the “We’re Done” section.
I ran the testapp. But when I did script/server, it said I had Ruby Gems 0.9.2 and I had to update to 0.9.4. I ran the upgrade, but got access errors. See below.
Does anyone know how to update or provide help? Again, I’m a complete novice. Thanks.
g5:/usr/local/src/testapp chrischen$ script/server
Rails requires RubyGems >= 0.9.4 (you have 0.9.2). Please `gem update—system` and try again.
g5:/usr/local/src/testapp chrischen$ cd ..
g5:/usr/local/src chrischen$ gem update—system
Updating RubyGems…
Bulk updating Gem source index for: http://gems.rubyforge.org
Attempting remote update of rubygems-update
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find rubygems-update (> 0) in any repository
g5:/usr/local/src chrischen$ gem update—system
Updating RubyGems…
Bulk updating Gem source index for: http://gems.rubyforge.org
Attempting remote update of rubygems-update
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /usr/local/lib/ruby/gems/1.8/cache/rubygems-update-1.0.1.gem
Chris C.
02 February 2008 at 6:29 pm
In my prior comments above, I had to upgrade to Ruby Gems 0.9.4. When I tried, I got an access error (see comments above).
Can I solve by rerunning the script in your article, but change ruby gems to the 0.9.4 version? Will this just rewrite over what we installed and cause no problems? Or is there a better/safer way to do this?
From the article: can I just change the 2 to a 4?
RubyGems
RubyGems is a handy command-line tool for managing the installation of Ruby packages, like Rails and Mongrel.
curl -O http://files.rubyforge.mmmultiworks.com/rubygems/rubygems-0.9.2.tgz
tar xzvf rubygems-0.9.2.tgz
cd rubygems-0.9.2
sudo /usr/local/bin/ruby setup.rb
cd ..
rubic
03 February 2008 at 1:07 pm
This is one of the more thorough installation tutorials I have come across after a weekend of searching out answers to a few questions.
Have you addressed the issue of the of the ‘tk (Load Error)’? I see this question posted all over the net with few ‘follow-able’ answers to the question. Could you direct me to an understandable solution?
Rubic
Desi
04 February 2008 at 7:12 pm
Hi Dan,
I just wiped my mac and installed Leopard on my box and I am just curious how the updated instructions are coming along? I would be willing to test the instructions for you if don’t mind helping me out if I run into issues.
Cheers
Desi
Imran Anwar
07 February 2008 at 12:59 am
Thanks for making the effort. I saw this post after I had already installed RubyStacks from Bitnami. I suspect others will be doing that too. But instead of losing that audience, it would be great if you post some items on how to leverage your posting even with their install.
regards
Imran
Chris
07 February 2008 at 3:13 pm
Great tutorial. I had one problem and wanted to provide the solution I discovered.
Here are the versions I used:
Mac OS X Tiger 10.4.11 (PowerPC G5)
Xcode 2.5
Ruby 1.8.6-p111
RubyGems 1.0.1
Rails 2.0.2
MySQL 5.0.51a PPC 64-bit (Installer Binary)
Everything worked as advertised until attempting to install the MySQL Native Bindings Gem:
sudo gem install mysql——with-mysql-dir=/usr/local/mysql
Building native extensions. This could take a while…
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb install mysql——with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… no
checking for mysql_query() in -lmysqlclient… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
[...]
The solution I obtained from:
http://blog.wearesakuzaku.com/installing-the-mysql-ruby-gem-on-os-x/
“What it’s complaining about is the fact that it can’t find your MySQL client libraries. You have to pass in the location of your MySQL installation using the following switch:
sudo gem install mysql——with-mysql-config=/usr/local/mysql/bin/mysql_config
“Many posts regarding the problems with this gem use the switch—with-mysql-dir. Don’t be confused ——with-mysql-config does basically the same thing, but apparently the mysql_config binary provides out all the command-line switches, including—with-mysql-dir, necessary for the installation…”
After this, it works flawlessly:
sudo gem install mysql——with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while…
Successfully installed mysql-2.7
1 gem installed
—
Thanks again!
Joseph
12 February 2008 at 12:32 am
I’d be looking forward to the Leopard tutorial.
Mike
12 February 2008 at 7:53 am
While installing the rails gen, if you are getting:
ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find rails (> 0) in any repository
try doing a:
sudo gem update
That did the trick for me.
Nostalgic Garden » Blog Archive » mysq
14 February 2008 at 2:03 pm
[...] error message on OSX Leopard 10.5.2, the chances are your PATH is not correctly saved. I followed Dan’s tutorial on installing MySQL on Leopard the other day and every time I had to do . /.bash_login to run the [...]
Prasad
16 February 2008 at 9:59 am
Hi, I am using MAc OS X tiger 10.4.9
I am getting the following issues.
I am always getting Ruby 1.2 instead of 1.8 on typing ruby -v at the bash shell prompt
I have used the vi editor to add the path for the .bash_login file. But how do i put it on the last line it was a new file - blank so there can be only one line and thats the first. I proceeded anyway
Also it says gem not found.
Kindly suggest. I am very excited about Ruby
and willing to lend a hand to the open source community
mysql Ruby Gem install Issues — solved! | Bu
21 February 2008 at 5:44 pm
[...] I ran into an issue today installing the ruby mysql gem on a fresh Leopard system with 10.5.1 installed and the MySQL 5 package for Intel installed. This is based on Dan Benjamin’s great work. [...]
Yome
29 February 2008 at 8:43 am
There is a new “release” of ruby :
ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p110.tar.gz
(look at the -p110)
Regards,
Yome
Yome
29 February 2008 at 8:59 am
!!! There is an major update for the RubyGems release :
http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
Regards
Yome
Yome
29 February 2008 at 9:45 am
Last link comes from my browser, so the good curl command is :
curl -O http://files.rubyforge.mmmultiworks.com/rubygems/rubygems-1.0.1.tgz
tar xzvf rubygems-1.0.1.tgz
cd rubygems-1.0.1
Jack
29 February 2008 at 9:45 pm
rails testapp
cd testapp
script/server
ERROR
Rails requires RubyGems >= 0.9.4 (you have 0.9.2). Please `gem update—system` and try again.
I found that the version of rubygems has be updated. Just replace 0.9.2 with 0.9.4.
http://files.rubyforge.mmmultiworks.com/rubygems/rubygems-0.9.4.tgz
Brilliant instructions. Very clear and easy to follow.
Tom Fahey
02 March 2008 at 12:50 pm
I would like to get a ruby on rails program for my mac. How do I do this?
Keith
03 March 2008 at 7:07 pm
Excellent guide. Totally stress free.
Thanks.
Ben
07 March 2008 at 3:19 am
Everything went smoothly until I came to the all-important step on installing Ruby on Rails. The following error came up. Please lend me your helping debugging hands…
My ibook G4 is using OS X 10.4 Tiger
ibook-g4:~/rubygems-1.0.1 ben$ cd ..
ibook-g4:~ ben$ sudo gem install rails—include-dependencies
sudo: gem: command not found
ibook-g4:~ ben$
bondibox
07 March 2008 at 3:54 pm
Tom, you can download sample code for a few rails books. Agile Web Development with Rails is one, and Practical Rails Social Networking Sites is another.
Ben, I’m guessing you have both .bash_profile and .bash_login files, and they’re conflicting.
Kevin
08 March 2008 at 10:13 pm
Ben, it sounds like either:
A) Ruby was not successfully installed or
B) You didn’t set up your path right.
Look for errors in the output from the ruby installation step to determine if A is the case. To see if B is the case, in your terminal, type “echo $PATH” without the quotes. You should see a list of paths separated by colons. If either /usr/local/bin or /usr/local are in there, then it’s not B.
Man this article has a lot of botspam.
Roger Pack
12 March 2008 at 11:19 pm
If you’ve installed mysql via MacPorts, then the mysql gem command will be
ruby extconf.rb—with-mysql-config=/opt/local/bin/mysql_config5
I believe.
Yagnesh
13 March 2008 at 4:34 am
How i start the ruby in windows platform?
and which editor will used for that?
also send me link of code to create ruby application for facebook.
Thanks
Yagnesh
JetPac
21 March 2008 at 1:59 pm
Great tutorial!
On Leopard the compilation fails like this:
gcc -g -O2 -fno-common -pipe -fno-common -DRUBY_EXPORT -L. main.o dmydln.o libruby-static.a -lpthread -ldl -lobjc -o miniruby
ruby: [BUG] Segmentation fault
ruby 1.8.6 (2008-03-03) [i686-darwin9.2.2]
You can fix it via applying the patch here - http://chopine.be/lrz/ruby-osx-patches/ignore-gsetcontext.diff
cd ruby-1.8.6
curl -O http://chopine.be/lrz/ruby-osx-patches/ignore-gsetcontext.diff
patch -p0 < ignore-gsetcontext.diff
This worked for me!
sarang
22 March 2008 at 4:16 am
Faced a lot of problems during installation.
I am a new user on Mac.. recently moved from windows to Mac.
Some of the tips which helped me resolve the issues I was facing….
1. make sure XCode is installed on ur Mac. It comes in the Cd/DVD that comes with Mac and is not installed by default.
2. If you want to do partial installation of XCode then make sure you install following components -
- Developer Tools
- gcc
- SDK.mpkg (or install all the *SDK.pkg files in XCode)
3. Use Ruby1.8.6 which is a stable version. Previously I was using ruby1.9.0 and faced many issues.
Hope this will be helpful to someone….
Cheers,
Sarang.
Student Loan Debt Relief
22 March 2008 at 1:42 pm
Student Loan Debt Relief
Many books you discover {will not have all you are searching for.
Justin
27 March 2008 at 12:20 am
This is a HUGE help. I’ve used it to set up Rails on several computers. Thanks!
David
30 March 2008 at 10:59 am
Rails newbie here. Every time I try and open the .bash_login file from the terminal I get file not found. Just using Mac’s TextEdit. I’ve tried showing hidden files but makes no difference. Failing at outset, oh dear! Any help?
Michael Lewis
30 March 2008 at 8:38 pm
Excellent instructions, however, I made the (bad) decision to use all of the latest releases (including the 64 bit mySQL server for the Mac OS/X). Everything worked great, except when I tried to use “requires ‘mysql’” I got a load error on “mysql.bundle”. When installing the mysql gem I received the following errors (which I ignored—bad decision).
ld64 warning: in /usr/local/lib/libruby.dylib, file is not of required architecture
ld64 warning: in /usr/lib/libz.dylib, file is not of required architecture
ld64 warning: in /usr/lib/libobjc.dylib, file is not of required architecture
The solution to the issue was to uninstall mySQL 64 bit and install the 32 bit version. Although I have a 64 bit operating system, the mysql gem and 64 bit mySQL do not play well together. I hope this helps the next person out there.
manuel
30 March 2008 at 11:55 pm
Hi,...
I’m just starting…
What if I get:
.bash_login: No such file or directory
when I try to run: ~./bash_login
And I can see the file using: ls -a
:-?
And thanks for the tutorial…
MixedContent
04 April 2008 at 5:27 pm
Anyone have pros/cons on using MySQL vs. SQLite3? Is there, e.g., a good reason behind the Rails team’s decision to change the default DB? Or is it just Coke vs. Pepsi?
JohnG
06 April 2008 at 2:45 pm
Everyone who has problems with ‘gem: command not found’, or apparently the wrong version of ruby running (ruby -v produces 1.8.2), or the dreaded error
/usr/local/bin/gem:3:in `require’: No such file to load—rubygems (LoadError)
the problem is likely with your path. Things to check:
* did you do the modification to .bash_login at the top?
* did you confirm it ‘took’, and you executed the ‘. ~/.bash_login’ command after?
The above two can be checked with ‘set’, and looking at the path variable to make sure it has what’s needed.
* is the version of Ruby you just installed the one you’re running? (‘which ruby’ will tell you where the ruby comes from; it should be /usr/local/bin)
* is there maybe another path with ruby in it *before* /usr/local/bin appears in your path?
* maybe you’re running from another terminal window that hasn’t run the newly configured .bash_login script, so the path is wrong?
(Just thought I’d list all the problems I had today…)
Everyone who has problems .bash_login not found, this is likely the normal starting configuration on a 10.4 Mac. If .bash_login doesn’t exist, you may have a .login file, which bash executes instead. Otherwise, creating a new .bash_login with the given command is OK.
Any chance this beautiful post can get updated with all the useful updated information in the comments?
Scott Goddard
20 April 2008 at 4:00 am
Dan, thanks for this tutorial.
However, I am getting an error with trying to install rails.
I put in:
sudo gem install rails—include-dependencies
and received
ERROR: While executing gem ... (NoMethodError)
undefined method `refresh’ for #<Hash:0x1111c18>
What does this mean?
Thanks, Scott
Scott Goddard
20 April 2008 at 4:40 am
In response to the error posted above,
I solved the problem by locating the source_cache file in gems with the following command:
gem env
The source_cache file was located in the path under “GEM PATH:”, I then proceeded to delete everything in the file (I suppose you could just delete it too) and saved it.
Next I updated gems:
sudo gem update—system
And finally to install rails:
sudo gem intall rails -y
Hope this helps anyone with the same issue. Several people are encountering this error, this webpage gave me the best help: http://weblog.rubyonrails.org/2007/2/6/in-case-you-re-having-trouble-installing-gems
Piers Goodhew
24 April 2008 at 1:47 am
Trying this with 10.2 (I know, I know, this is not for any serious purpose), the make of readline failed with:
gcc: -compatibility_version only allowed with -dynamiclib
but, thanks to : https://stat.ethz.ch/pipermail/r-sig-mac/2005-August/002205.html
I ran make as follows and it all worked (at least, readline did, now compiling ruby)...
make CPPFLAGS=-DNEED_EXTERN_PC SHOBJ_LDFLAGS=-dynamiclib
Rosano
28 April 2008 at 11:19 pm
For those of you trying to change the default database to MySQL, I don’t think it is possible. The default was changed to SQLite in 2.0.2:
http://weblog.rubyonrails.org/2007/12/17/rails-2-0-2-some-new-defaults-and-a-few-fixes
Irakli Nadareishvili
29 April 2008 at 1:44 pm
Thanks for a wonderful walk-through. I had one problem, though. Below is the problem def, with a solution.
Immediately after the installation of the gems, local source repo is empty, so if you just run
sudo gem install rails—include-dependencies
It will give you an error, complaining that no package with the name “rails” was found.
You need to run:
sudo gem list—remote
which will fetch gem modules list from a remote server and only then try to install rails.
Adam Ehven
30 April 2008 at 11:04 am
Hi. Just wanted to say thanks for the tutorial, works great.
RainMann
01 May 2008 at 3:54 pm
I stumbled a little on the .bash_login step. Here are some things to keep in mind:
David: I had to create my own .bash_login file - it goes in your user directory or /Users/YourUserName/ .
When I tried the “~/.bash_login” command, it said: “Permission denied”. That’s cause it’s the wrong command :)
Manuel: make sure you type “. ~/.bash_login” (as in “dot space tilda slash dot bash_login”)
RainMann
01 May 2008 at 5:18 pm
@daken: I got the same error:
“ERROR: While executing gem ... (Gem::GemNotFoundException)
Could not find rails (> 0) in any repository”
I just tried it again and it worked, possibly just a server/bandwidth issue
RainMann
02 May 2008 at 3:33 pm
Great tutorial!
Thanks to Chris (with whom I happened to share an identical software/architecture profile) for the solution to the mysql gem installation blip I also encountered.
I’m excited! Thanks again!
liujie
05 May 2008 at 12:53 pm
Thanks for the tutorial ,It’s very useful.
phil
06 May 2008 at 7:40 am
Excellent tutorial!! Thank you!!
I followed this exactly and everything seemed to work correctly. However, when I launched testapp, the WEBrick server was used rather than Mongrel. Did I miss a path or configuration step?
Jason
09 May 2008 at 8:48 pm
Thank you for the tutorial! My computer does not like this… I can’t seem to get past the very first part.
I’m running 10.4.11. I’ve created the .bash_login file and tested it… but here’s what I get
***********
Last login: Fri May 9 17:26:16 on ttyp1
Welcome to Darwin!
-bash: {rtf1macansicpg10000cocoartf824cocoasubrtf470: command not found
-bash: /Users/jay-ota/.bash_login: line 2: syntax error near unexpected token `}’
-bash: /Users/jay-ota/.bash_login: line 2: `{fonttblf0fswissfcharset77 Helvetica;}’
***********
Gah! What is this?
Jason
09 May 2008 at 10:42 pm
Ahah! Nevermind. I used textedit to create the file and somehow all those hidden commands that specify font, color and such must have gotten saved with it. I used vi in terminal and cleared the problem up.
Nat
12 May 2008 at 6:44 pm
Bingo man! What a tutorial. Took me 75 minutes but everything is fine ... I am riding on the Rails baby!
Aidan C.
15 May 2008 at 5:15 pm
Hi, I hope someone is still reading this far down the comments and can help.
I must admit first off that I have done very very little with the terminal or linux type commands.
I’m getting the “ruby 1.8.2” problem, which has been mentioned in previous comments.
That first step of ammending the .bash_login file was very problematic for me. I downloaded text mate to try to try to keep rigidly to the tutorial and copy and paste whenever possible, but the listed command didn’t work for me. I made the file, copying in the appropriate lines, in text wrangler and saved (got the warning message that it would be a hidden system file) and was even able to view the file in the terminal with vi and the appropriate lines appear to be there.
The ~/.bash_login command was responded to with a “Permission denied” which is frustrating. I do have the correct password for all the sudo commands.
The tutorial suggests I “go back and check my work” but I think I’m too severely a n00b for that to mean anything to me.
John G in the comments suggested using the ‘set’ command, but I don’t follow what he meant for us to do.
Can any kind, patient people help me out here?
Aidan C.
16 May 2008 at 3:56 pm
Following up on my earlier comment:
I saw some of the other comments mentioned editing the .bash_profile file. I don’t have that file, just the .bash_login file I created (which doesn’t seem to be doing what I hoped it would) and a .bash_history file.
any suggestions?
snowmaninthesun
16 May 2008 at 10:53 pm
If you run into a problem installing ruby and are getting an error saying , try manually creating a blank /Library/Ruby folder, along with blank /usr/bin/ruby and /usr/bin/gem folders. (if you want to open the bin directory simply type open /usr/bin). I had to do this to get my install to work correctly. I also changed on line on configuration to
./configure—prefix=/usr/local—disable-pthread—with-readline-dir=/usr/local—enable-shared
hope this helps
Rich
17 May 2008 at 10:20 pm
Fantastic article - so useful for those of us using older computers. Thank you.
Ethan
18 May 2008 at 1:15 am
.Bash_login PATH SOLUTION
Copy and paste the path command above directly into your command line in root, you don’t need to modify the .bash_login file.
This took me a while, but it works