Monday, 18 October 2010

Getting RVM, Textmate, Ruby 1.8.7 and 1.9.2 and Rails 3 to play nice

It's taken a while of fighting though various blog posts to get to a mac with a stable Textmate, RVM, two versions of Ruby (1.8.7, 1.9.2) and two versions of Rails (2.3.8 and 3.0.x).
Without further ado, here are the hard steps I've worked through to get it all working:

RVM

use .rvmrc to set your projects to the right ruby/gemset (create a gemset as well):
cd myproject
rvm 1.9.2@myproject
Build textmate wrapper following the rvm instructions, then replace contents of textmate_ruby file:
#!/usr/bin/env sh

source ~/.rvm/scripts/rvm
cd .
exec ruby "$@"

RSpec Bundle

Update this to a very recent version. (from github)
Also set RUBYOPT to rubygems in Shell Variables under the Advanced tab in TextMate setttings.

RSpec

gem install rspec-rails
Follow instructions here:

Plist fix for textmate

Shut down textmate:
Make sure you are using ruby 1.9.2
rvm use 1.9.2

Then:
git clone git://github.com/kballard/osx-plist.git
cd osx-plist/ext/plist
rm plist.o
ruby extconf.rb && make
mv /Applications/TextMate.app/Contents/SharedSupport/Support/lib/osx/plist.bundle /Applications/TextMate.app/Contents/SharedSupport/Support/lib/osx/plist.bundle.old
cp plist.bundle /Applications/TextMate.app/Contents/SharedSupport/Support/lib/osx/
Restart textmate

Git.tmbundle

mkdir -p ~/Library/Application\ Support/TextMate/Bundles
cd ~/Library/Application\ Support/TextMate/Bundles
git clone http://github.com/jcf/git-tmbundle.git Git.tmbundle

Ruby on Rails.tmbundle

The Ruby on Rails bundle will need to be reinstalled as well to avoid the following error
Ruby on Rails.tmbundle/Support/bin/intelligent_migration_snippet.rb:71:in /bin/bash:
-c: line 0: unexpected EOF while looking for matching `'' /bin/bash: -c: line 1: syntax error: unexpected end of fileto_a' for "\n\n def self.down\n    drop_table :tags\n  end\nend\n":String (NoMethodError) from Ruby on Rails.tmbundle/Support/bin/intelligent_migration_snippet.rb:96:in
Find the update and install instructions at http://github.com/drnic/ruby-on-rails-tmbundle

No comments: