Ruby shared-mime-info gem and OS X

February 18, 2008

For anyone doing stuff requiring a good MIME library in Ruby, shared-mime-info works well. On OS X a few things are necessary to make it work though.

First, use ports to install the shared-mime-info database:

sudo port install shared-mime-info

Then you have to set XDG_DATA_DIRS to point at the right place on OS X, which is /opt/local/share. Put this in your .bashrc file:

export XDG_DATA_DIRS=:/opt/local/share

XDG_DATA_DIRS is where freedesktop.org stuff looks to find files, and if not specified will look in /usr/share or /usr/local/share. Since ports on OS X puts everything in /opt/local, you have to set it.

That's pretty much it! If you don't install the shared-mime-info database and set the ENV variable the gem will still work, just not as well (returning text/plain instead of text/css for css files, etc.)

Add comment

About

I'm a programmer and shutterbug living on the West Coast of Canada.

Blog Archive

Recently Heard

A Liberal Educationby New Model ArmyPlayed on 2008/07/16 at 02:35PM
The Two Sides of Monsieur Valentineby SpoonPlayed on 2008/07/16 at 02:32PM
You Weren't Thereby New Model ArmyPlayed on 2008/07/16 at 02:28PM
Powered by Viviti