So you got the gem install activerecord-mysql2-adapter problem?

Today while installing a little sinatra app into a friend macbook, i ran into the following piece of hell:

`establish_connection’: Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (no such file to load — active_record/connection_adapters/mysql2_adapter) (RuntimeError)

As i couldn’t possibly find that gem, i started searching the internet after a solution. About an hour later (and several frustrated attempts) i was finally able to solve the problem by issuing the following command:
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /lib/mysql2/mysql2.bundle
Note that you need to replace with the current path to mysql2 gem (if you use rvm, chances are that it is like
~/.rvm/gems/ruby-1.8.7-p334\@mygemset/gems/mysql2-0.2.11
Hope it helps!

  • Robert Bodley

    Thanks but when I do these commands it says the command cannot be found. Im on a mac

    • http://techie.lucaspr.im Lucas d’Acampora Prim

      which command cannot be found? have you already installed mysql?

  • Clemens

    what do you mean with ‘Note that you need to replace with the current path to mysql2 gem’ ?

    • Clemens

      what is ‘/lib/mysql2/mysql2.bundlez’ ?

      • http://techie.lucaspr.im Lucas d’Acampora Prim

        i have no idea, found this googling! the command “sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib/lib/mysql2/mysql2.bundle” does work as intended!

    • http://techie.lucaspr.im Lucas d’Acampora Prim

      the gems in your system are stored inside a folder, the path to the mysql2 gem is the path that takes to the gem, including the path to your system gems, like ~/.gems/mysql2