Thursday 20 March 2008

Gotcha when upgrading rails on Mac OS X Leopard

One of the first things I did when receiving my new MacBook was to upgrade the Rails installation to 2.0.2, the standard installation of Rails on Leopard is 1.2.6.

Updating is simple, so long as you remember one little "gotcha".
$sudo gem update --system
$sudo gem update

Now here is the gotcha. Rails 2.0.X now has an new element, active resource, which is not upgrade by the standard upgrade path.
If you get the following error then its likely that you hav'nt updated rails properly.
$ rails
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:379:in `report_activate_error': Could not find RubyGem activeresource (= 2.0.2.9053) (Gem::LoadError)

so the solution is to either...
$sudo gem install rails

or
$sudo gem install activeresource


You dont need to use --include-dependancies anymore, its the default on the current version of rubygems.

Note also that the standard rails distribution on Leopard does not include a mysql driver, i will produce a post on how to upgrade this later.

Tuesday 18 March 2008

Holy grails on Mac OS X Leopard

In an earlier post I showed how to install "groovy", a "ruby" like language, that runs on top of the Java VM, it is the backbone of the Grails initiative which aims to provide a Rails like environment on the Java Platform, Groovy is to Grails, as Ruby is to Rails.

This time I'm going to show you how to install and setup Grails on leopard. If this post looks simular to the groovy post, then thats because the method for installing the two are very simular, and I have a cut and paste button, and imm feeling lazy.

Prerequisites

First make sure you have java and its dev tools setup on your machine see this post on how to do that.

Now download grails from the grails site.

Unpack the archive and move it to /usr/share , for example:
$ sudo mv ~/downloads/grails-1.0.1 /usr/share 
Now set ownership and permissions on the directories
$cd /usr/share
$sudo chown -R root:wheel grails-1.0.1/
$sudo chmod 0755 grails-1.0.1/bin/*

Now create a symlink to access the current version of grails by, if you download and install another version later, you can just move the symlink to point at it, this is a good practice as it prevents you having to overwrite your old installation.
$ln -s grails-1.0.1 grails

Finaly add the following to your /etc/profile or ~/.profile depending on wether you want it available for all logons or just your own.
GRAILS_HOME=/usr/share/grails; export GRAILS_HOME
And the following to your path in the same file, note your path should be defined after the above
PATH = $GRAILS_HOME/bin:$PATH; export PATH
Now your ready to try it out and see if it works, open up a terminal and type:
$grails

Welcome to Grails 1.0.1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/share/grails

No script name specified. Use 'grails help' for more info
$
Cool, it works.

Scaling it up.

Around about this time last year, I gave a presentation at BarcampLondon2 on scalability in low end web services. The presentation was targeted at small startups and sole web developers and aimed to give them some insights into how to harden a site against burst traffic. 

Anyway some kind soul thought it was good enough to upload to Scribd , so you can read this now slightly dated presentation here

Groovy on Mac OS X Leopard

Groovy is the new "Ruby" like language that runs on top of the Java VM, it is the backbone of the Grails initiative which aims to provide a Rails like environment on the Java Platform, Groovy is to Grails, as Ruby is to Rails. 

This post will show you how to setup groovy on Leopard, and allow you to explore this intriguing new language.

Prerequisites

First make sure you have java and its dev tools setup on your machine see this post on how to do that

Now download groovy from the groovy site. 

Unpack the archive and move it to /usr/share , for example:
$ sudo mv ~/downloads/groovy-1.5.4 /usr/share 
Now set ownership and permissions on the directories
$cd /usr/share
$sudo chown -R root:wheel groovy-1.5.4/
$sudo chmod 0755 groovy-1.5.4/bin/*
Now create a symlink to access the current version of groovy by, if you download and install another version later, you can just move the symlink to point at it, this is a good practice as it prevents you having to overwrite your old installation.
$sudo ln -s groovy-1.5.4 groovy
Finaly add the following to your /etc/profile or ~/.profile depending on wether you want it available for all logons or just your own. 
GROOVY_HOME=/usr/share/groovy; export GROOVY_HOME
And the following to your path in the same file, note your path should be defined after the above
PATH=$GROOVY_HOME/bin:$PATH; export PATH
Now your ready to try it out and see if it works, open up a terminal and type:
$groovyConsole
The groovy console window should open up as shown above, thats it your done, stay tuned for more groovy news.

Monday 17 March 2008

Leopard's A+ scorecard with Java

In preparation for looking at groovy, grails, hadoop and hypertable , I decided to get my macbook setup to run ant, maven, junit etc. After a bit of searching and scouring the net, I found a number of tutorials, on how to get this environment running, showing how to download and install this package, and that package, set up this file and add these lines to here and there, until my head was spinning.

However its is a LOT simpler than that. Just install XCode 3.0 TOOLS, from the optional installs section of your Leopard distribution disk and it will install and setup
/usr/share/ant -> ant-1.7.0
/usr/share/maven -> maven-2.0.6
/usr/share/junit -> junit-4.1

and it will throw cvs, subversion and a multitude of other tools in for good measure. Unfortunately Xcode 3 wont run on Tiger (10.4.x), where you are stuck with Xcode 2.5, which may not setup all this goodness, but since i dont have a Tiger Machine anymore, i cant verify this.

So: to start the investigation of the java frameworks/platforms listed above, I just added the following to the end of my /etc/profile, to make sure the packages can find the installed goodies.
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home; export JAVA_HOME
ANT_HOME=/usr/share/ant; export ANT_HOME
MAVEN_HOME=/usr/share/maven; export MAVEN_HOME
JUNIT_HOME=/usr/share/junit; export JUNIT_HOME

Saturday 8 March 2008

Ruby off the Rails

In keeping with my new years resolutions, i have been struggling to learn Ruby On Rails, so armed with an existing PHP application that i wished to replicate in rails (as a learning exercise, i do'nt recommend that you seriously consider re-factoring a mature application in rails).

This is a three fold learning exercise, first learning ruby the language, then rails, then how to run and deploy rails on Mac OS X, my operating system of choice.

One of the things i have learnt so far, is that unlike compiled languages, interpreted languages can tie you up in knots, trying to work out why something that seems to run does not do what you want it to do.

I guess the next thing i will have to learn is how to get the ruby debugger running, or i'm going to be even more prematurely bald.

So im running:

Mac OS X leopard on a MacBook, with the Apple ruby. mysqly.ab sourced MySQL 5.0.51, Aptana Studio as my IDE and Mongrel as the web server.

Getting that lot to co-exist was adventure in its own right (and may be the subject of another post), but now i have it working its a pretty slick environment, i reckon in the last 10 hours I have done as much work as would have taken me a week to get running in PHP or C++.

So off to find out how to make debugging work in the IDE, i managed it once, but only after considerable fiddling.

BTW: the new MacBooks are wicked developer workstations, the Black MacBook came with 250G Drive and 2G ram, and is as fast as hell, faster than my 3 gen MacBook Pro that i recently gave up.

Now wheres that debugger documentation :-)

Yahoo Vs Microsoft

Somebody sent me this cool video mashup on facebook. Some of the humor is very "inside" to Yahoo, its very funny none the less. It was made by Amr, who works for the US search team..