RSS icon Home icon
  • Mac OS X Snow Leopard + Rails, MySQL, and Sphinx

    Posted on August 26th, 2009 schmeeve 13 comments

    Ah, Snow Leopard. While you’re admiring the photoshop job Apple did to the box art, you may be eager to install the new Leopard, but hang on if you’re using Rails.

    If you’re getting the following types of error with the mysql driver, you may need to reinstall.

    The error:

    !!! 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): no suitable image found. Did find:
    /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle: mach-o, but wrong architecture - /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle

    The fix:

    sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

    (h/t here)

    Sphinx/Ultrasphinx:

    If sphinx is already installed (and searchd starts up without issue), you may be set. However, if you’re installing it new, you’ll want to compile it in 32-bit mode:

    Download the latest tarball of Sphinx here.

    ./configure CFLAGS="-O -arch i386" CXXFLAGS="-O -arch i386" LDFLAGS="-arch i386" --disable-dependency-tracking
    make
    make install

    RMagick:

    NOTE: Despite trying this, I still am having issues with RMagick. If anyone’s got tips…

    UPDATE: As per Dimitri’s (big hat tip!) post below, I *finally* got everything going using MacPorts, which I hadn’t realized was updated for Snow Leopard yet.

    Didn’t go so smoothly, but finally succeeded. Just threw in the towel and got my old MacPorts install out of the way and started over.

    To uninstall MacPorts completely (big caveat: this will uninstall everything previously installed with MacPorts):

    sudo port -f uninstall installed
    
    sudo rm -rf /opt/local \
    /Applications/MacPorts \
    /Applications/DarwinPorts \
    /Library/Tcl/macports1.0 \
    /Library/Tcl/darwinports1.0 \
    /Library/LaunchDaemons/org.macports.* \
    /Library/StartupItems/DarwinPortsStartup \
    /Library/Receipts/MacPorts*.pkg \
    /Library/Receipts/DarwinPorts*.pkg \
    ~/.macports

    Then installed libxml2 and ImageMagick as Dimitri recommends, followed by:

    sudo port install rb-rubygems
    sudo gem install rmagick
    
     

    13 responses to “Mac OS X Snow Leopard + Rails, MySQL, and Sphinx”

    1. Dimitri Roschkowski

      Hi!

      Today I also got my SnowLeopard copy and updated my 10.5 System to 10.6. Yeah well, as you, I had some problems with the RoR installation but after about 4 hours I finally got it.

      In your blog, you asked for some tips about the RMagick installation. First of all, the mentioned script installs some outdated versions, that’s why I used another way. First of all, I installed the current version of MacPorts (for SnowLeopard).

      http://distfiles.macports.org/MacPorts/MacPorts-1.8.0-10.6-SnowLeopard.dmg

      Then I tried just to install ImageMagick, that failed for me, because of libxml2 compiled for the i386 architecture. So you have to recompile / update it first.

      sudo port install libxml2
      sudo port install ImageMagick

      It was enough for to have a running x64 version of ImageMagick on SL. It could be, that some other libs are compiled in i386, too. Than you have to update it first before compiling ImageMagick.

      My next step was the installation of the RMagick gem. It’s maybe a bug, but after my first run of

      sudo gem install rmagick

      I get the error, that rmagick was configured for a wrong version if ImageMagick, after the second run of the gem install rmagick, I hat a working solution.

      I hope, I could help you with your problem

      – Dimitri

    2. Hi guys

      Excellent to see you put in the effort to help Snow Leopard users see what needs to be done to do RoR work on their machines.

      I would also love to see if tools like Bitnami’s RubyStack (that I had previously used and found easy to install) can be included in the notes above if things have to be done differently by users of Bitnami installed RoRs.

      It would also be great if a paragraph can be added on what exactly you know Apple developer tools pre-includes related to RoR and what it doesn’t. e.g. if Ruby, Apache and SQLite are already in Mac OS X Snow Leopard, does one need to deploy a whole separate environment whether Bitnami or MacPorts or other or can just some missing parts be added?

      The reason I ask is that though Bitnami had installed easily on my Mac Book Pro in the past, something about the way Apple’s Ruby and the 3rd party Ruby were mentioned in the paths actually broke my working app Novamind Platinum. (The Novamind people included a fix in their next version to specifically look for what they needed instead of assuming Ruby or whatever from Apple was the only one in use).

      So I would love to know how to use as much of Apple’s bundled stuff with minimal duplicated languages or frameworks or database servers.

      Sorry for the long comment, but as a learner I have more questions that I hope help you and others help others… thank you Jerry McGuire. :-)

      Imran
      IMRAN.TV

    3. [...] Snow Leopard, Mysql, and Sphinx [...]

    4. Just what I needed, thanks for the post. And the comment :)

    5. Peter Iwanowitsch

      Thanks mate.
      Your simple code is the right thing for my problems .. with the RMagick installation.

      Best

    6. The mysql arch for my had to be
      sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
      otherwise you get a path issue.

    7. uninstalle mac ports…
      and used :

      http://github.com/maddox/magick-installer/tree/master

      that’s the way to do it !

    8. The Mysql fix didn’t work for me. I got an error about ruby.h not being found:

      $ sudo env ARCHFLAGS=”-arch i386″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
      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
      mkmf.rb can’t find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

      Anyone else get this?

    9. Jason F — It looks like you don’t have XCode installed. The Ruby headers are installed along with the XCode installation which can be found on the Snow Leopard installation disc.

    10. Hi,

      I installed ImageMagick with this script here because it seemed the most up to date one and I had trouble with the Mac Ports installation: http://github.com/masterkain/ImageMagick-sl

      I get the following error in some ImageMagick commands:

      Magick::ImageMagickError: Wrong JPEG library version: library is 70, caller expects 62 `’ @ jpeg.c/EmitMessage/232

      Can anybody advice? What do I need to do?

    11. Its fixed now. There was an older version of the jpeg lib from Mac Ports which needed to be removed before running the Image Magick install script.

    12. [...] to schmeeve over at d27n for the tip. Comment | Trackback URL Short Link: Add a [...]

    13. Use this

      http://garrickvanburen.com/archive/installing-imagemagick-rmagick-on-os-x-10-6-snow-leopard

      works a treat

    Leave a reply