Skip to content

Diving (back) into ruby on rails

March 21, 2009

First lesson learned: if you’re like me and you bought a new mac recently that came with OS X 10.5, and you have installed the developer tools (from your install DVDs), then more likely-to-work instructions for installing ruby on rails on mac os x 10.5:

$ sudo gem update --system
$ sudo gem install activeresource
$ sudo gem update
$ rails path/to/your/new/application
$ cd path/to/your/new/application
$ ruby script/server

How the lesson was learned

I abandoned Ruby on Rails somewhere in its 1.x days because it was unstable, evolving too fast, and because the deployment architecture (FastCGI) was stupid. The later seems to have gotten much better, and apparently my macbook even comes with rails installed. Rails is on version 2.3, which “sounds” pretty mature. So let’s dive in!

I go to this page and click the red get started arrow. The download page scares me a bit with comments about upgrading to ruby 1.9, but I figure out I should be able to do this:

sudo gem update rails
mkdir foo
rails foo

But I get this:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:379:
in `report_activate_error': RubyGem version error: rake(0.7.3 not >= 0.8.3) (Gem::LoadError)
	from .../rubygems.rb:311:in `activate'
	from .../rubygems.rb:337:in `activate'
	from .../rubygems.rb:336:in `each'
	from .../rubygems.rb:336:in `activate'
	from .../rubygems.rb:65:in `active_gem_with_options'
	from .../rubygems.rb:50:in `gem'
	from /usr/bin/rails:18

Ploughing on looked like it would be depressing:

$ sudo gem update rake
$ rails foo
$ ... RubyGem version error: activesupport(1.4.4 not = 2.3.2) ...

Grr. Time for a bit of RTFM.

$ gem help
$ gem help commands
$ sudo gem update

It seems I’m now installing various not-yet-1.0 tools with impressive names such as acts_as_ferret and hpricot. I also got a bunch more errors:

ERROR:  Error installing RedCloth:
	RedCloth requires RubyGems version >= 1.2
ERROR:  While generating documentation for actionpack-2.3.2
... MESSAGE:   Unhandled special: Special: type=33, text="TODO"
ERROR:  While generating documentation for activerecord-2.3.2
... MESSAGE:   Unhandled special: Special: type=33, text="Fixtures"
ERROR:  While generating documentation for activesupport-2.3.2
... MESSAGE:   Unhandled special: Special: type=33, text="TODO"
ERROR:  While generating documentation for acts_as_ferret-0.4.3
... MESSAGE:   Unhandled special: Special: type=33, text="Ferret"
ERROR:  Error installing capistrano:
	capistrano requires RubyGems version >= 1.2
ERROR:  While generating documentation for daemons-1.0.10
... MESSAGE:   Unhandled special: Special: type=33, text="All"
ERROR:  Error installing fastthread:
	fastthread requires RubyGems version >= 1.2
ERROR:  While generating documentation for ferret-0.11.6
... MESSAGE:   Unhandled special: Special: type=33, text="Provides"
ERROR:  While generating documentation for highline-1.5.0
... MESSAGE:   Unhandled special: Special: type=33, text="A"
ERROR:  While generating documentation for hpricot-0.7
... MESSAGE:   Unhandled special: Special: type=33, text="Detect"
ERROR:  While generating documentation for libxml-ruby-1.1.2
... MESSAGE:   Unhandled special: Special: type=33, text="The"
ERROR:  While generating documentation for mongrel-1.1.5
... MESSAGE:   Unhandled special: Special: type=33, text="Alias"
ERROR:  Error installing net-sftp:
	net-sftp requires RubyGems version >= 1.2
ERROR:  Error installing net-ssh:
	net-ssh requires RubyGems version >= 1.2
ERROR:  While generating documentation for ruby-openid-2.1.4
... MESSAGE:   Unhandled special: Special: type=33, text="A"
ERROR:  While generating documentation for sqlite3-ruby-1.2.4
... MESSAGE:   Unhandled special: Special: type=33, text="This"

Even less impressive:

Gems updated: RedCloth, actionmailer, actionpack, activerecord,
activesupport, acts_as_ferret, capistrano, daemons, dnssd,
fastthread, ferret, highline, hpricot, libxml-ruby, mongrel,
net-sftp, net-ssh, ruby-openid, rubynode, sqlite3-ruby

It says it failed to install RedCloth, but then later on it says it updated it anyway! I wonder if I just b0rked my out-of-the-box ruby setup… Pressing on, according to the RubyGems docs I need to run

$ sudo gem update --system
...
RubyGems installed the following executables:
	/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem

If `gem` was installed by a previous RubyGems installation, you may need
to remove it by hand.
$ ls -l `which gem`                                                                                                                                             dev
/usr/bin/gem ->
   ../../System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem

Will it be happier, now?

$ sudo gem update
Updating installed gems
...
Gems updated: RedCloth, net-ssh, net-sftp, net-scp, net-ssh-gateway,
capistrano, fastthread

That looks ok. Looks like I’ll be lacking some documentation for some of my gems, but I can live with that. Try again:

$ rails foo
/Library/Ruby/Site/1.8/rubygems.rb:636:in `report_activate_error':
Could not find RubyGem activeresource (= 2.3.2) (Gem::LoadError)
	from /Library/Ruby/Site/1.8/rubygems.rb:141:in `activate'
	from /Library/Ruby/Site/1.8/rubygems.rb:165:in `activate'
	from /Library/Ruby/Site/1.8/rubygems.rb:164:in `each'
	from /Library/Ruby/Site/1.8/rubygems.rb:164:in `activate'
	from /Library/Ruby/Site/1.8/rubygems.rb:49:in `gem'
	from /usr/bin/rails:18
$ gem list | grep active
activerecord (2.3.2, 1.15.6)
activesupport (2.3.2, 1.4.4)

Not impressed. Time to go find a list of dependencies. Oh, its the last one remaining. Duh.

$ sudo gem install activeresource
$ rails foo
      ...
      create  log/test.log
$ cd foo
$ ruby script/server
$ curl http://localhost:3000/

Yay! Success. Time taken to get rails 2.3.2 install on OS X: ~40 mins. Current mood: feel like an idiot. Feel like ranting about how to do dependency management that doesn’t suck at the ruby/rails community, and about testing your installation instructions. Time for coffee.

Advertisements
6 Comments
  1. April 27, 2009 22:43

    Thank you, worked like a charm. Onward through the wilderness…

  2. Wei permalink
    July 8, 2009 21:45

    Thanks for the post!

  3. John permalink
    July 30, 2009 16:22

    I was in the exact same situation that you were. This post saved me a heap of time and pain, thanks!

  4. Celso Dantas permalink
    August 5, 2009 21:19

    Niiiiice post! Got stucked with that too. thanks! =]

  5. October 2, 2009 9:37

    great little piece! thanks!
    sid

Trackbacks

  1. Diving into ruby on rails part 2 « LSD::RELOAD

Comments are closed.

%d bloggers like this: