Installing Ruby and Ruby On Rails from scratch on OS X using DarwinPorts / MacPorts

Ruby OS X graphic

I've created a screencast that shows you how to setup the following from a fresh install of Mac OS X Tiger (10.4.8):

I started by installing OS X on a firewire drive, then I setup the basic stuff you'll need to develop in Ruby and Ruby on Rails. Although Locomotive does a good job of getting you started fast, this screencast shows you how to move past that and install the latest versions of everything via DarwinPorts / MacPorts in the command-line.

Here is the profile shown in the screencast. For more information on how to completely customize your bash startup files, read my article here.

I set the resolution to 800x600 and I recorded the whole screen, so that you see everything that I do, without missing pieces.

InfiniteRed Screencast 001
68.9mb Quicktime file, 28 minutes long

Note: I set, in the screencast, the path and aliases in the /etc/profile file. That was intentional; I do realize the the best way to do this is to put the path in the profile (or ~/.bash_profile), and the aliases and such in the /etc/bashrc (or ~/.bashrc) file, and then reference bashrc from the profile. However, this approach, although ideal, is complicated and mostly isn't necessary in OS X for a new command-line user. In OS X, the profile is read every-time a new Terminal window or tab is created; which is different behavior from some other Unices. The only time, in OS X, that using only the profile is a problem is when you create a new non-login shell by calling "bash" from inside an existing shell. For more information on how to completely customize your bash startup files, read my article here.

  1. jp February 05, 2007 22:35 

    Nice!

  2. cls February 20, 2007 18:35 

    This is a great screencast!

    Everything went fine until after darwinports were installed. After sudo bash, the port sync (or port list command) gives command not found (Tiger 10.4.8 macbook pro intel 2 ghz)

  3.  February 20, 2007 20:16 Todd

    You probably don't have your profile setup correctly, and port isn't in your path. Try this:
    /opt/local/bin/port sync

    If that works, then that's the problem. Make sure you setup your "profile" as described in the screencast. If you did that correctly, then make sure you are using it; you do that either by restarting iTerm (or terminal) or by creating new tab in iTerm (command t)

    The "set" command will tell you your path, it should look something like this:
    PATH=/opt/local/bin:/opt/local/sbin:/Users/Todd/bin:/bin:/sbin:/usr/bin:/usr/sbin

    I'm glad you liked the screencast.

  4. cls February 20, 2007 21:01 

    Thanks !
    so /opt/local/bin/port sync worked, as did /opt/local/bin/port sync update. Running 'set' in terminal gives:
    path (/usr/local/bin /bin /sbin /usr/bin /usr/sbin)

    However - even though I copied and pasted your profiles, I think some programs are in v. weird places - a spotlight search for ruby and darwinports shows:

    ruby seems to be installed in : /opt/local/var/db/dports/sources/
    rsync.rsync.darwinports.org_dpupdate_dports/lang/ruby

    Ruby is certainly not in /opt/local/bin

    darwinports is in:
    /opt/local/var/db/dports/sources/rsync.rsync.darwinports.org_dpupdate1/
    base/src/darwinports1.0

    Any suggestions to get stuff in the right place and delete all the stuff in the wrong place? (doesn't apple preinstall ruby in the 'wrong' location prior to shipping - ie, I may not be the only viewer with this issue...

    Thanks

    cls

  5.  February 22, 2007 08:06 Todd

    cls,

    Your path isn't setup right, you'll need to fix that for everything to work well. There are many different ways to setup your path, but the one in the screencast works well, so I'd double check everything you did.

    You may simply delete (throw in the trash) the opt folder and start over if you like, everything DarwinPorts installs is in that one folder.

  6. TJ March 09, 2007 13:31 

    Nice. I've added to my Ruby tips collection on TekTag.

  7. chdono April 01, 2007 05:05 

    Hi Todd would you help me,

    I follow your tutorial, everything goes fine until i tried
    port install ruby.

    Error occur, it said Dependency 'zlib' not found, than stop.

    What should i do? when i gogling that said that zlib already included in os x.

    I can't instal rb-rubygems too, willing u help me.

    best regard's
    -d0n0-

  8. DannyBoyNYC July 11, 2007 20:38 

    Very well done. Everything work perfectly for me. Now if only the same magic could be aid of my attempt to install mySQL via ports. The install itself was flawless but my ability to configure and use it were lacking and hampered by contraditry postings elsewhere.

    Why is it that my attempts to larn Ruby are always stymied by mySQL?

  9.  July 12, 2007 08:08 Todd

    Yeah, installing MySQL via ports is easy, but you have to configure it and everything manually, which can be a bit of work. The nice thing about that is everything is installed in the /opt directory and setup exactly how you like.

    The easy way to get going is to use the binary package they provide for OS X: dev.mysql.com/downloads/mysql/5.0.html#downloads. Frankly, I tend to just do this now, rather than manually doing it. The package version is suppose to be optimized for OS X, from what I've read, but I don't know if that is true or not.

  10. Tom August 16, 2007 16:06 

    Excellent screencast! I do have one question though about the message you (and I) receive after the install:

    "config/boot.rb:38:Warning: require_gem is obsolete. Use gem instead."

    Its pretty annoying when you have a ton of tests, but when I try to change the boot.rb command as instructed, it does not work. Any info you can provide?

  11. Tom August 16, 2007 16:28 

    I don't know if this is related to my previous post, but I also seem to have an issue now with the IRB launched from a breakpoint. I just opened up one of my tests and threw a breakpoint in. When I run the test, it drops me into the IRB but without my variables?

    irb(test_create(FieldTest)):001:0> local_variables
    => ["id", "block", "_"]

    I've googled around and haven't found anything remotely similar from other folks?

  12. Chris October 10, 2007 05:37 

    Tom, I'm getting the same thing with IRB on Ubuntu. Like you, I haven't found much reference to other folks having the same problem.

  13. Thom August 28, 2008 22:50 

    Followed through your awesome screencast (got here from nettuts.) Anyway I get to the very end, I try to go to :3000/hi and get:

    Routing Error

    No route matches "/hi" with {:method=>:get}

    Any help?

  14. Thom September 01, 2008 13:26 

    No help?

    I lied, it started to mess up earlier. After starting the server, and clicking the about environment, I get a big red box that says something like missingsourcefile.

    i37.tinypic.com/33jqvcz.png

Comments are closed for this article.
Feel free to contact me on twitter if you have any questions or comments: @twerth.