Tag Archives: osx

Bundler, OSX and the MysqlCompat::MysqlRes error

If you get the uninitialized constant MysqlCompat::MysqlRes error when trying to run your Rails app all the evidence points to it being a 32 v 64 bit issue.  However, I had built mysql for the x86_64 architecture and the mysql gem installed was also for 64 bits.  So why was I still getting this error.  It turns out that bundler was building the mysql gem in 32 bits.  OSX Snow Leopard ships with Ruby in a universal binary containing the ppc, i386 and x86_64 binaries and for whatever reason bundle install was using the 32 bit ruby and re-building everything even though I had the gems already installed in the system in 64 bit mode.  This could be because the user doing the building was 1) unprivileged and 2) using bundle install \--path=vendor.  Maybe bundler was picking the first version of ruby that was appropriate to the platform.  However, doing bundle install \--deployment also had the same issues. I have no idea why it was rebuilding gems that already existed on my system. The way to get round it was to force bundler to build in 64 bits by using env ARCHFLAGS='-arch x86_64' bundle install --path=vendor
Maybe the best idea is not to use the Ruby that ships with OSX and build one appropriate to your environment in the first place.

RServe on OSX Snow Leopard

I always seem to have some difficulty getting the Rserve component of the R stats library up and running on OSX.  Installing it via install.packages(“rserve”) from within R  appears to work but when running R CMD Rserve I usually get some sort of error like:

/Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: Rserve: not found

Compiling from source using the download from http://rosuda.org/Rserve/ never seems to work with all sorts of C related horror.

However, the Rserve component actually was installed but it looks like the paths/links were not quite right.  Typing this:

R CMD /Library/Frameworks/R.framework/Resources/library/Rserve/libs/x86_64/Rserve.so

Got everything up and running. Doing this:

cp /Library/Frameworks/R.framework/Resources/library/Rserve/libs/x86_64/Rserve-bin.so /Library/Frameworks/R.framework/Resources/bin/Rserve

fixes it a bit more permanently

More bits == better? AKA Snow Leopard broke my Gems

Snow Leopard install went fine.  Running methodbox after this didn’t.  ImageMagick, libxml and mysql gems were all broken.  Followed this advice to get it all working.  Boils down to re-install MacPorts, install ImageMagick and libxml2 from ports, re-install the RMagick and libxml-ruby gems, install mysql-64bit, re-install mysql gem (in 64 bit mode).

Easy!!  Only took 2 hours.  So that’s about 4 hours (and 2GB+ downloads) for the snow leopard upgrade so far!

Also found this script for installing ImageMagick.  I couldn’t get it to work but maybe you can.

Cross platform fun

While debugging some test problems with the T2 code I discovered some issues between OSX and Windows regards file paths and line breaks.  Seems that instead of just

inputs.put(“fileUrl”, LocalworkerTranslator.class.getResource( “/AAC4_HUMAN.sp”).getFile());

you have to ensure that the absolute path is correct by doing

URI uri = LocalworkerTranslator.class.getResource(“/AAC4_HUMAN.sp”) .toURI();

File newFile = new File(uri);

inputs.put(“fileUrl”, newFile.getAbsolutePath());

Also, you can’t expect checks for “\n” style line breaks to work in Windows because they insert things like “\r\n” instead.  So , you should use System.getProperty(“line.separator”) instead.