Right Way to Install Rails on Mac OS X?

After a bit of a break I'm taking a look at Rails again for web development. The idea is that I'm going to develop locally using Locomotive, then deploy to the Xserve. My question this: what's the current and correct way to install Rails on Tiger? I've done a bit of a Googling, and there are a lot of different answers.

HiveLogic has one of the most well-known installation guides, but this is nearly a year old. Does all of this still apply?

Justin has his version at MacZealots, but this is from more than a year ago. Maybe Justin could speak up and tell me if this is still valid information? :)

There's this page on the Rails Wiki which has all sorts of different pointers and recommendations.

Robby on Rails has a walkthrough which is just a few months old, so that's a bit more promising.

This script from Nuby on Rails looks very intersting, but I have no idea who this guy is. He says the script is based on the HiveLogic tutorial. Does he know what he's doing?

Here's yet another one from Nano Rails.

Does all of this still apply in Mac OS X Server 10.4.8? A number of tutorials talk about installing DarwinPorts / MacPorts. That's fine, but I don't need an entire package management system for one framework, right?

I'm sure there's a good reason that there are so many different sets of instructions, but it would be nice if there was one main installation guide. Also, what am I supposed to be using for deployment? Some sort of  FastCGI something-er-other? I don't need something super-special or custom. I'm looking for the 80% rule.

The good news is that it looks like Rails will be bundled with Leopard.
Design Element
Right Way to Install Rails on Mac OS X?
Posted Oct 18, 2006 — 18 comments below




 

Mr eel — Oct 18, 06 2084

My advice is to install macports, then use that to install the latest version of Ruby and RubyGems. Export /opt/local/bin to your search path (I forget the precise steps here I'm worry) Then use ruby gems to install rails

sudo gem install rails --include--dependencies

Gems are the way to go. Easy to upgrade or remove as you need, and it manages any dependencies nicely.

Going for macports might seem like overkill, but seriously it makes it so much less painful, especially if you decide to use a new version of MySQL or a different web server like Lighttpd.

Tony Arnold — Oct 18, 06 2085

I second Mr eel's approach. Personally, I find it much easier to let MacPorts (or Fink) do it's business. This way, you can easily upgrade to the latest point release of Ruby as they are put out, and there's no buggering about with MySQL /Postgres dependencies if you choose that path (although experience has shown me that sqlite3 databases are much easier to deal with both in dev and production).

DeLynn Berry — Oct 18, 06 2086

I'm a fan of the Nuby-On-Rails script. Geoffrey Grosenbach certainly knows what he's doing, and I've used the script to install the entire stack on at least three different machines with no problems what-so-ever.

Personally, I think using ports is a bit much (but I have used it before as well and it works).

As for deployment, I'm really fond of running either Apache, Lighttpd or (my new favorite) Litespeed up front to handle static requests, and then proxying your Rails requests off onto a Mongrel instance or cluster.

Ryan Raaum — Oct 18, 06 2087

I use MacPorts (mostly) to build the Locomotive bundles, but it's not necessary if you're planning a fairly basic ruby/rails install. On 10.4.x server all that you need for a basic rails install is readline, ruby, rails, mongrel, and mysql bindings.

However, if you are going to want to use ImageMagick/RMagick, I would definitely go the MacPorts route (some of the image libraries can be a serious pain to build from scratch).

Other suggestions:

1. Whatever recipe you use, don't bother with lighttpd+pcre+fastcgi, just install mongrel.

2. Don't follow any recipe that has you "fixing" Apple's ruby. Sooner or later Apple will mess up your fix with an update or some application will have a script that expects the version of ruby that comes stock with Apple.

Scott Stevenson — Oct 18, 06 2088 Scotty the Leopard

Whatever recipe you use, don't bother with lighttpd+pcre+fastcgi, just install mongrel

Gladly.

Matt Tavares — Oct 18, 06 2090

Whatever recipe you use, don't bother with lighttpd+pcre+fastcgi, just install mongrel

Mongrel is blindingly fast. Although, they don't have support for my favorite plug-in: Upload Progress.

Oh, and im pretty sure Dan editied the hivelogic post to accomodate intel machines.

Justin Williams — Oct 18, 06 2091

Mine is a bit dated, but it uses Apache rather than Lighttpd. I'd say go for Dan Benjamin's if you want Lighttpd.

Dale — Oct 18, 06 2092

Ah, open source documentation. 'Tis wondrous.

James Duncan Davidson has an up-to-date guide for installing Rails on Mac OS X. This guide will be going into the 2nd edition of Agile Development with Rails.

The latest thinking is to use Mongrel either with, or instead of, FastCGI because it's both faster and more reliable. (Hopefully Mongrel will replace Webrick in Ruby soon.)

Locomotive is great for development, but deploying rails apps is not at all simple because of all the dependencies. I'm sure Rails will eventually cop criticism for this, and I'm surprised it hasn't been tackled by the Rails team given they're mostly Mac users (ie the 'it just works' Mac experience).

I don't expect the local development situation to be substantially improved in 10.5 either. While Rails, and the latest version of Ruby compatible with Rails, are likely to be installed, I expect some issues will remain. That is: Rails doesn't come with a Hello World style project for people to get up & running with; most tutorials assume MySQL which isn't bundled with the 10.4 client and isn't free; and Rails apps require minmal database configuration to do anything. It would be nice if 10.5 bundled the latest stable Rails (1.2.x?) an Ruby, provided a simple Hello World style web app configured to use sqllite and Mongrel.

As well, Apple haven't suggested that maintaining Rails, Ruby, sqllite, Mongrel, ruby-gems, MySQL, etc in 10.5 will be improved. For example, we haven't heard anything about Apple providing an elegant package management program to ease the pain for power users.

Alex Payne — Oct 18, 06 2093

Another vote for MacPorts. The trunk version of Rails ("Edge") is compatible with Ruby 1.8.5, so don't hesitate to go for the latest and greatest. Postgres is also available from MacPorts. Hint, hint.

I strongly recommend developing against Edge. You'll get the latest in features, and missing out on the new RESTful conventions is a waste of time. It's how Rails apps are going to be written, henceforth, and it makes more sense.

Skip Locomotive and manage the toolbox of Rails dependencies yourself. When it comes time for production deployment, you'll be glad you did.

As for servers, just use Mongrel while developing. When production time rolls around, get cozy with a Mongrel+Apache setup. It's the best of both worlds and not too horrible to set up. Lighttpd is neat but its codebase is going through a lot of overhauling right now.

I'd be happy to answer questions you may have. Good luck!

David Winter — Oct 18, 06 2094

I literally, an hour ago, used the Hivelogic steps on my MacBook, 10.4.8 and it worked a dream.

Jeroen Leenarts — Oct 18, 06 2095

Indeed, installing rails can be a huge pain on OSX.

And uhm, the rb-rubygems package in macports/darwinports seems to be broken. Instead rb-rails is the prefered way of getting rails through darwinports. The rb-rubygems port

Here's my take on it: http://blog.leenarts.net/2006/09/22/error-installing-rails/

The problem is, that there just doesn't seem to be a recommended way of installing rails. Basicly if you are not using darwinports, a packaged install of ruby gems is the way to go. If you're using darwinports or fink, then you are basicly obligated to install ruby/rails/other dependencies directly through your package manager and not through ruby gems.. Because all use /opt/local to put their installations. Things can get really hairy real fast when working with a mixed (rubygems/package manager) set-up.

Scott Stevenson — Oct 18, 06 2096 Scotty the Leopard

Matt Tavares said: Mongrel is blindingly fast. Although, they don't have support for my favorite plug-in: Upload Progress.

Looks like that was fixed on June 25 (0.3.13.2)?

Dale said: James Duncan Davidson has an up-to-date guide for installing Rails on Mac OS X. This guide will be going into the 2nd edition of Agile Development with Rails

This looks pretty complicated. Is it all really necessary if I'm not running, you know, a cluster of load-balanced, plasma-powered machines? I'm not building a replacement for MySpace.

I don't mind typing commands and waiting for 20 minutes for things to come together, but I do mind spending two days Googling for error messages and the like. Do I really need a sandbox and all that? 80 percent rule.

I'm surprised it hasn't been tackled by the Rails team given they're mostly Mac users (ie the 'it just works' Mac experience)

I'm surprised too. I think the one thing Mac OS X shows us is that's okay to trade some modularity for an easier experience. Maybe it's the DRY thing taken to an extreme -- the point it actually makes things harder for developers?

most tutorials assume MySQL which isn't bundled with the 10.4 client and isn't free

How do you figure it's not free? There's certainly a non-free edition, but that's not the only option.

Michael Koziarski — Oct 18, 06 2097

Hey Scott,

If you're just looking to get Rails up and running, Dan's HiveLogic guide is a great option. He updates it regularly, so don't be too worried by the publication date.

If you are considering running more 'stuff', then go with macports.

The trunk version of Rails ("Edge") is compatible with Ruby 1.8.5, so don't hesitate to go for the latest and greatest.

That's not actually accurate, there are still some 1.8.5 related bugs which we haven't managed to fix, stick with 1.8.4 to be certain. Though if you're happy without the breakpointer, you can probably survive with 1.8.5.

Hope you enjoy using our framework, and thanks for all the interesting cocoa resources.

Michael Koziarski — Oct 18, 06 2098

I think the one thing Mac OS X shows us is that's okay to trade some modularity for an easier experience.

Once you have a functioning ruby interpreter (i.e. not the broken one apple ships) it really is just a matter of installing ruby gems and 'gem install rails'. Alternatively, you can just download the zip file version, expand it, and start coding.

Mayo — Oct 18, 06 2099

I would recommend MacPorts approach as well. Gives you system independence (apple updating ruby, etc) and you can easily replicate your development environment on multiple machines regardless of the OS version. Duncan's guide isn't as complex as it seems, it just includes some steps for it to include some user friendliness in the long run. Steps 1 through 3 is just installation of MacPorts, Steps 4, 5 are Ruby and Rails, but you don't really need to install all of them. For simple setup, just install ruby+rails+mongrel+whatver gems you need, though I seriously recommend subversion+capistrano, if you are even a little bit serious about the development.

For the simplest setup, you could just go with the Ruby that's included in OSX, install gem support and install everything from gems, but be aware that there are some version and other issues with Rails and the Ruby Apple ships bundled in the OS.

In any case, welcome back to the Rails works and have fun :) Feel free to drop me a line if you need anything.

Pascal — Oct 19, 06 2101

On 10.4.8, and now that MacPorts transition is complete, you need to tweak some of the older instructions (including mine). I wrote an update for 10.4.8 yesterday or the day before that.

including a fix for compiling rb-mysql (the native mysql driver which gives much improved performances)

Pascal — Oct 19, 06 2102

Thanks for the reference too!

BTW, Mongrels with dispatcher in front (apache or others) seems to be the trend these days. FastCGI is good when it works, but when it loses the connection, things go downhill for a while...

srame — May 17, 09 6766

o ja pierdolę




 

Comments Temporarily Disabled

I had to temporarily disable comments due to spam. I'll re-enable them soon.





Copyright © Scott Stevenson 2004-2015