How to Fix: Library not loaded: libmysqlclient.18.dylib

9th July, 2011 Patrick

Just installed OS X Lion and after installing RVM, Rails, and MySQL I went to got start one of my rails projects and received this great message.

/Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.3/lib/mysql2.rb:7:in `require': dlopen(/Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.3/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.3/lib/mysql2/mysql2.bundle
  Reason: image not found - /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.3/lib/mysql2/mysql2.bundle
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.3/lib/mysql2.rb:7:in `<top (required)>'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `require'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'
    from /Users/patrick/Workspace/MonkeyOnCode/config/application.rb:7:in `<top (required)>'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.0/lib/rails/commands.rb:28:in `require'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.0/lib/rails/commands.rb:28:in `block in <top (required)>'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.0/lib/rails/commands.rb:27:in `tap'
    from /Users/patrick/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.0/lib/rails/commands.rb:27:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

This is simply an issue with mysql2 not being able to find the MySQL provided dynamic library. The easy way to fix this is simple add the below value to your ~/.bash_profile and you will need to source the file again or start a new terminal.

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH

Rails Wizard

28th June, 2011 Patrick

I just ran across nifty little tool called RailsWizard which I am going to start using to bootstrap my rails projects. You can quickly select which frameworks you want to include, and it will disable exclusive packages. Once your ready, you simply select "Finish" and it provides you with a rails command that uses a template that will be downloaded from the RailsWizard and will start the install process. I would say for most of my projects A single template will work for most but for when you want to work outside to box this makes it quick and simple.

Hello Ruby On Rails

21st December, 2010 Patrick

Today was a big day for my little blog. I have been playing with Ruby on Rails the past 3 months in a effort to migrate my blog from the basic WordPress themed sight to my own custom template that runs on rails. So here it is in all its glory, and its been a interesting road.

Ruby is an interesting language that I really came to enjoy using. I now find myself reaching for my ruby tools before anything else when creating my one off scripts. At first the flexibility in the language syntax made the learning curve pretty steep. I learn a lot by reading existing code from people who know how to write code. Ruby is far from cut and dry in its syntax, from blocks with either do/end or curly braces, the numerus ways for creating arrays, to methods that have "=" at the end, missing parenthesis, with parenthesis and DSLs. Before I felt entirely comfortable with the syntax I spent a lot of time researching, trying to figure out the magic that happens in just a couple lines of code.

Rails really enabled me to develop new pages and services quickly. Now I was not able to out the gate quickly build pages, technically I was, but I wanted to really understand what was going on under the hood. Rails is truly convention based development, where I would say 80 to 90 percent of what you want to do falls into the conventions of typical web development. The exciting thing about rails is its ability to handle the other 10 to 20 percent in a clean consistent way.

I have a lot more to add to this blog, a lot of it will exist in the admin section, but I will be adding comments as well. I have enjoyed my time in Ruby and Rails and this will not be my last rails project. Please remember this site is still a work in progress and things might break from time to time.