When Ruby goes wrong

Cool/funny/stupid stuff, Ruby on Rails, Technology 3 Comments »

Running the tests, 1 failure. Doesn’t look like a failure to me :)

Investigating…


1) Failure:
test_new_articles(AnnounceArticleFunctionalTest)
[test/functional/announce_article_test.rb:74:in `test_new_articles'
/usr/lib/ruby/gems/1.8/gems/mocha-0.5.6/lib/mocha/test_case_adapter.rb:19:in `__send__'
/usr/lib/ruby/gems/1.8/gems/mocha-0.5.6/lib/mocha/test_case_adapter.rb:19:in `run']:
<Wed, 21 May 2008 15:12:50 +0000> expected but was
<Wed, 21 May 2008 15:12:50 +0000>.

No nonsense GIT, part 1: git-remote-branch

Software development 12 Comments »

We’re just starting to use GIT at Defensio and although there are plenty of great resources like the Peepcode video and Jean-François Couture’s blog, the learning curve (from SVN) can be a little rough. The problem is that GIT is very powerful, and probably too powerful for a small shop like ours. This unfortunately leads to some complexity that we’d rather not have to deal with, especially since we don’t need all the fancy features.

In an effort to simplify our workflow, we started to build a few scripts that automate complex tasks. My plan is to post them on my blog for your own benefit. If they’re useful for us, they should be useful for other people too.

The first script I’m posting is git-remote-branch. It is meant to simplify the process of creating and deleting remote and local tracking branches. Instead of having to execute multiple commands, easy to remember one-liners are now enough. (hey! we’re lazy!)

Check this out:

This command creates an experimental branch on a remote server (’origin’ by default) from the one you’re currently sitting in, then a local tracking branch. When that’s done, it checks out to the newly created local branch.  You can then pull and push as you wish.

This command does the same as the previous one, but creates experimental on ‘origin2′ instead of ‘origin’.

When you’re done dealing with the remote/local branch combo you created, you can delete both in one go:

The script will delete the remote branch, then check out “master” if you’re still sitting in “experimental”. The local “experimental” branch is then deleted.

git-remote-branch can be downloaded here. Make sure to chmod +x it before executing it. For the record, it’s written in Ruby.  Let me know if it’s useful for you!

How to fix that Rubygems mess on Leopard

Ruby on Rails, Software development 27 Comments »

I love Leopard and I love my Mac. I think Apple made the right decision by bundling Ruby and Rails with Leopard. However, I believe they screwed up big time in the execution.

Leopard’s Rails installation worked great until I updated Rubygems with sudo gem update –system. After I did that, most of my gems were broken, and reinstalling them didn’t help. According to Google, I was not alone.

The right thing to do for Apple would have been to ship Leopard with MacPorts and have Ruby and Rubygems installed through it. Unfortunately, they had to reinvent the wheel…

This tutorial will guide you through fixing that mess. We will be reinstalling Ruby and Rails with MacPorts and deleting the original Ruby installation to avoid conflicts.

You might want to backup your system before proceeding as I cannot be held responsible if something goes wrong (my lawyer made me write that). I tried it on 2 different machines and it worked fine for me.

So let’s get started already!

Step 1: Install MacPorts

Start by installing MacPorts if you don’t already have it on your machine. It’s an awesome must-have piece of software anyways! It’s super easy to install with the Leopard package.

Step 2: Install XCode 3.0

You must also have XCode 3.0 installed. It’s a huge download so you might want to install it from your Leopard DVD. It’s in /Optional Installs/Xcode Tools/XcodeTools.mpkg

Installation will take some time, so go read Digg, Reddit, or install Defensio on your blog!

Step 3: List your gems

Get a list of your installed gems and save it to a text file somewhere. You will need to reinstall them!

Step 4: Clean up your Mac

In order to avoid conflicts with your original Ruby installation, I recommend you simply delete it. To do so, run these commands (I know… scary stuff!):

Step 5: Install Ruby and Rubygems with MacPorts

If you don’t perform step 4, you will run into problems at step 6.

Now go ahead and install Rubygems through MacPorts. It will automatically install Ruby (and many other things) as it’s a dependency. The command is:

This one will also take a while… When it’s done, update Rubygems:

Step 6: Install Rails

At this point, you should have a brand new Ruby and Rubygems installation working! That wasn’t too hard was it?

Now let’s install Rails.

  • For Rails 1.2.6, run
  • For Rails 2 (aka latest-and-greatest), run

Note that recent versions of Rubygems no longer requires the –include-dependencies parameter.

Step 7: Reinstall your gems

Now’s the time to reinstall your original gems.

To reinstall the gems that shipped with Leopard, execute this command:

Then, you might want to reinstall the other gems you had. The list is on your desktop in installed_gems.txt.

That’s it! You now have a more standard and less prone to problems Rails stack on your Mac!

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in