Dec 11 2009

Migrating Rails 2.3 to Snow Leopard

Earlier this year I blogged about installing Rails 2.2 on Leopard. I recently upgraded my MacBook to Snow Leopard, so it was time to do the MySQL dance all over again.

Rather than reiterating what I did, here are the three resources that I found most useful in getting things sorted:

As with my previous experience, the most difficult & frustrating part of the exercise turned out to be getting the MySQL gem working properly. I found the commentary in the last post to be particularly helpful in getting the MySQL resolved.

Related Posts:


Jan 16 2009

Installing Rails 2.2 on OSX Leopard

In my few spare moments, I like to hack Ruby on Rails. Non programmers are free to tune out at this point.

I recently tried to install and configure the recently released Rails 2.2. Among the changes therein, the MySQL driver is no longer included – you need to install the mysql gem.

The standard gem installation did not work:

$ sudo gem install mysql
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
	ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql

After a bit of googling, it turns out you need to give a bit more information for this gem:

$ sudo bash -c "ARCHFLAGS='-arch i386' gem install mysql -- \
	--with-mysql-config=/usr/local/mysql/bin/mysql_config"
Building native extensions.  This could take a while...
Successfully installed mysql-2.7
1 gem installed

While this installed the gem, it still did not fix the problem:

!!! The bundled mysql.rb driver has been removed from Rails 2.2.
Please install the mysql gem and try again: gem install mysql.
rake aborted!
dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9):
  Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib
  Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
  Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle

Some further googling later, it transpires that you need to muck about with the dynamic link libraries:

$ sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib \
	/usr/local/mysql/lib/libmysqlclient.15.dylib \
	/Library/Ruby/Gems/1.8/gems/mysql-2.7/mysql.bundle 
$ sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib \
	/usr/local/mysql/libmysqlclient.15.dylib \
	/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle

These last two commands look very similar, but there’s a subtle difference between them: there are two different paths to separate instances of the libmysqlclient.15.dylib file.

And low and behold:

$ irb
>> require 'mysql'
=> true

And there was great rejoicing. Note that this solution is specific to Mac OSX Leopard. It will work for Tiger, apparently, but you need to change some of the paths in the last two commands.

We will now return you to your regular programming.

Related Posts:


May 9 2007

Now with FOAF

Thanks to this entry from Aidan Finn, who incidentally is now working in the SFI funded DERI, I finally got around to putting up a simple FOAF file on my blog.

Adian’s post is pretty clear, but there are a few minor adjustments necessary to get it to work in Typo:

  • The foaf.rdf file should be created in the ~/typo-4.1.1/public/ directory.
  • To create the auto-discover link (point 3 in Aidan’s steps), put the following in the <head> of the default.rhtml file in your theme (e.g. ~/typo-4.1.1/themes/azure/layout/default.rhtml):

<%= stylesheet_link_tag "/foaf.rdf", :media => 'all', :rel => 'meta', :type => 'application/rdf+xml', :title => 'FOAF' %>

  • Don’t forget to empty the fragment cache in Typo’s admin panel to force the new default.rhtml to be used.

Related Posts:


May 9 2007

Typo theme weirdness

Hmmm, it appears that the Ghostpaper theme that I’m using for this blog doesn’t show articles when you select them by their permalink.

I’ll have to investigate. In the meantime, I’m switching back to the default Azure theme.

Related Posts:


May 8 2007

Upgrading typo

As I mentioned in a previous post, a new version of Typo is available. I upgraded this evening, and here’s the steps that I followed.

  • Check out the latest version from the SVN repository:

$ svn co http://svn.typosphere.org/typo/trunk typo-4.1.1

  • Copy over my old .htaccess file:

$ cp ~/typo-4.0.3/public/.htaccess ~/typo-4.1.1/public

  • Copy over my old database.yml:

$ cp ~/typo-4.0.3/config/database.yml ~/typo-4.1.1/config/database.yml

  • Update the database schema
mysql> select * from schema_info;
+---------+
| version |
+---------+
|      50 |
+---------+
1 row in set (0.00 sec)

$ cd ~/typo-4.1.1
$ rake db:migrate

mysql> select * from schema_info;
+---------+
| version |
+---------+
|      63 |
+---------+
1 row in set (0.00 sec)
  • Copy over my theme:
$ cd ~/typo-4.1.1/themes
$ tar zxvf ~/typo-4.0.3/themes/ghostpaper.tgz
  • Copy over my uploaded files:
$ cd ~/typo-4.1.1/public
$ cp -r ~/typo-4.0.3/public/files .

You might notice the absence of a backup step at the start of this process. I n general the db:migrate action appears to be very robust and trustworth. However, I have a scheduled backup of my DB anyway, so I didn’t need to do it explicitly. However, I would certainly recommend it as a first step.

Total time – about 30 minutes. Not too bad.

Thoughts? On first blush, it certainly appears to be snappier than 4.0.3. The other noticeable change is an improved admin interface. So far so good – looks like a worthwhile upgrade. Recommended.

Related Posts:


Apr 18 2007

New version of Typo!

I’ve just noticed that Typo, the Ruby-on-Rails blogging engine that powers this site has become active again, after what appears to be a long hiatus.

The developers have also released a new version – v4.1. As soon as I get a chance, I’ll have to install it, and check it out. They have also started a blog, so hopefully this means a renewed level of development activity.

While I like the idea of my blogging software running on RoR, I must say that sticking with Typo has not been without its frustrations. I have often been tempted to move to the behemoth that it Wordpress. However, the killer app for me, is support for Textile. If you’re not familiar with it, check it out. You’ll never (or at least rarely) have to deal with HTML or a crappy HTML GUI again.

Related Posts: