Installing Rails on a Mac

What a lot of grief!

After trying more simple steps on another site (and failing) I eventually managed to get the following steps to work:

There were however some changes:

01: Make sure you download TextMate. I kept reading it as TextEdit for some reason, so just be aware of that when “mate ~/.bash_login” wont work.

02: One of the steps tells you to type “make ~/.bash_login”. I found that adding the suggested text to that file made no difference when you log out/in or close the Terminal window. This was because a file named “~/.bash_profile” existed. If this file exists then you should modify it instead of the one mentioned in the article.

03: When trying to do “rake db:migrate” I would experience the following error:

otherwise you will experience the following error:
dyld: NSLinkModule() error
dyld: Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib
Referenced from: /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Reason: image not found
Trace/BPT trap

This is because the latest version of MySql has changed a path from lib/mysql to just lib/. To fix this problem you need to type the following (it’s all one line):

sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle

Right then. Now that those Hellish few days are over it’s time to get annoyed with trying to write a website I suppose 🙂

7 thoughts on “Installing Rails on a Mac

  1. thank very much to both blogger and anonymous

    After reinstall mysql sinatra don't run and show message like:

    LoadError: dlopen(/usr/local/lib/ruby/gems/1.8/gems/do_mysql-0.10.0/lib/do_mysql_ext.bundle, 9): Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.16.dylib

    Using datamapper with sinatra do_mysql

    try this

    sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /usr/local/lib/ruby/gems/1.8/gems/do_mysql-0.10.0/lib/do_mysql_ext.bundle

    and works on

  2. Using datamapper with merb and mysql, has to also do:

    sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib /usr/local/lib/ruby/gems/1.8/gems/do_mysql-0.9.1/lib/do_mysql_ext.bundle

    Thanks, would never have worked that out!

  3. Dude! You just made my sunday morning. This helped big time.


  4. Thanks. I had to change my path for the bundle to /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle
    Otherwise, smooth sailing

  5. Pointed me in the right direction for a related issue. I chose to fix the mysql libraries with:

    for i in *dylib ; do
    sudo install_name_tool -id $PWD/$i $i;

    run from /usr/local/mysql/lib.

Leave a Reply

Your email address will not be published. Required fields are marked *