Library not loaded: libpq.5.dylib - ruby-on-rails

I have app that is running Ruby 1.9.2, Rails 3, and postgreSQL 8.3. It was originally setup and working with postgreSQL 9.1, but I uninstalled 9.1 and installed and changed to 8.3 insure compatibility on a Heroku shared database setup. It was running ok, but it's not now
Now, when working on this app, when I run a database upgrade I get this error:
dlopen(/Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle, 9): Library not loaded: libpq.5.dylib
Referenced from: /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle
Reason: no suitable image found. Did find:
/usr/lib/libpq.5.dylib: no matching architecture in universal wrapper - /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle
And when I try to run the server I get this error message:
/Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg.rb:4:in `require': dlopen(/Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle, 9): Library not loaded: libpq.5.dylib (LoadError)
Referenced from: /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle
Reason: no suitable image found. Did find:
/usr/lib/libpq.5.dylib: no matching architecture in universal wrapper - /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg_ext.bundle
from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.12.2/lib/pg.rb:4:in `<top (required)>'
from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290#global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290#global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290#global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290#global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290#global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290#global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290#global/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /Users/michaeljmccoy/www/mikemccoy/config/application.rb:7:in `<top (required)>'
from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0.rc2/lib/rails/commands.rb:53:in `require'
from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0.rc2/lib/rails/commands.rb:53:in `block in <top (required)>'
from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0.rc2/lib/rails/commands.rb:50:in `tap'
from /Users/michaeljmccoy/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.0.rc2/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I know they are very similar errors and probably has to do with a missing path. However, when I add the path to my .profile file and restart the terminal window, I get the same errors.

You may need to remove and re-install the pg gem, so it's compiled against the correct version of Postgres.

For anyone seeing this error and running PostgresApp, this is a known problem that was fixed in version 9.2.4.3:
Discussion: https://github.com/PostgresApp/PostgresApp/issues/109
Installer: https://github.com/PostgresApp/PostgresApp/releases/tag/9.2.4.3
Of course, you could just grab the latest version (http://postgresapp.com/). Both versions got me back up and running with Rails 3.2.14 and Ruby 2.0.0. However, note that when I installed 9.2.4.3 my databases were still listed in psql, but when I installed 9.3.0 (the current version at the moment), my databases were no longer listed.

Related

Broken Rails references when macOS x is updated

Today, I update my macOS x to Mavericks, and my projects on rails doesn't works.
when I run my project with the command
rails server
display me the follow error:
/Users/Jarvis/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
require':
dlopen(/Users/Jarvis/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin12.0/digest/sha1.bundle,
9): Library not loaded:
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (LoadError)
Referenced from:
/Users/Jarvis/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin12.0/digest/sha1.bundle
Reason: image not found -
/Users/Jarvis/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/x86_64-darwin12.0/digest/sha1.bundle
from
/Users/Jarvis/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
require' from
/Users/Jarvis/.rvm/gems/ruby-2.1.1#global/gems/bundler-1.6.2/lib/bundler/definition.rb:1:in
<top (required)>' from
/Users/Jarvis/.rvm/gems/ruby-2.1.1#global/gems/bundler-1.6.2/lib/bundler.rb:153:in
definition' from
/Users/Jarvis/.rvm/gems/ruby-2.1.1#global/gems/bundler-1.6.2/lib/bundler.rb:116:in
setup' from
/Users/Jarvis/.rvm/gems/ruby-2.1.1#global/gems/bundler-1.6.2/lib/bundler/setup.rb:7:in
' from
/Users/Jarvis/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
require' from
/Users/Jarvis/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
require' from
/Users/Jarvis/Documents/Projects/Vincubo/vincubo/config/boot.rb:4:in
<top (required)>' from bin/rails:7:inrequire_relative' from
bin/rails:7:in `'
It depends a bit on what version of OSX you upgraded from.
But basically, you should reinstall the ruby version using rvm

Rmagick errors when running Rails S after upgrading to OSX Mavericks 10.9

I updated my osx to Mavericks 10.9 from 10.7, and since then I have been having issues running 'rails s'.
The issue is with Rmagick, and I have tried almost every solution that I could find. Most people recommended reinstalling imagemagick through homebrew, and reinstalling rmagick gem, but that didn't work. I even uninstalled homebrew as a whole, and reinstalled it. I tried getting rid of gemfile.lock, and running bundle install again, but none of these worked.
Here is the error message I get when I try running the rails local server:
Kibaeks-MacBook-Pro:onvard_saas kibaek$ rails s
/Users/kibaek/.rvm/gems/ruby-2.1.0#onvard/gems/rmagick-2.13.2/lib/rmagick.rb:11:in `require': dlopen(/Users/kibaek/.rvm/gems/ruby-2.1.0#onvard/extensions/x86_64-darwin-12/2.1.0-static/rmagick-2.13.2/RMagick2.bundle, 9): Library not loaded: /usr/local/lib/libMagickCore.5.dylib (LoadError)
Referenced from: /Users/kibaek/.rvm/gems/ruby-2.1.0#onvard/extensions/x86_64-darwin-12/2.1.0-static/rmagick-2.13.2/RMagick2.bundle
Reason: image not found - /Users/kibaek/.rvm/gems/ruby-2.1.0#onvard/extensions/x86_64-darwin-12/2.1.0-static/rmagick-2.13.2/RMagick2.bundle
from /Users/kibaek/.rvm/gems/ruby-2.1.0#onvard/gems/rmagick-2.13.2/lib/rmagick.rb:11:in `<top (required)>'
from /Users/kibaek/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `require'
from /Users/kibaek/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Users/kibaek/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `each'
from /Users/kibaek/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `block in require'
from /Users/kibaek/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `each'
from /Users/kibaek/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `require'
from /Users/kibaek/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.5.1/lib/bundler.rb:131:in `require'
from /Users/kibaek/onvard_saas/config/application.rb:13:in `<top (required)>'
from /Users/kibaek/.rvm/gems/ruby-2.1.0#onvard/gems/railties-3.2.16/lib/rails/commands.rb:53:in `require'
from /Users/kibaek/.rvm/gems/ruby-2.1.0#onvard/gems/railties-3.2.16/lib/rails/commands.rb:53:in `block in <top (required)>'
from /Users/kibaek/.rvm/gems/ruby-2.1.0#onvard/gems/railties-3.2.16/lib/rails/commands.rb:50:in `tap'
from /Users/kibaek/.rvm/gems/ruby-2.1.0#onvard/gems/railties-3.2.16/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I had trouble with this as well on OS 10.9. I tried many things and this is what worked for me (after installing Xcode 5):
brew install libtool --universal
brew link libtool
Quick research just found the following with other users who also had success:
Stack Overflow: rmagick-error-after-installing-os-x-mavericks
TheKUnit Blog: RMagick errors running rake tasks os x maverick
Edit: Another possibility is that you have a different version of RMagick than the gem is looking for (possibly from the reinstall). Your log shows your gem is looking for /usr/local/lib/libMagickCore.5.dylib which I am guessing it cannot find. Do
ls /usr/local/lib/
and see if you can find that file. If not, a
gem pristine rmagick
may help if you haven't already tried it. In my case I have Core 6 in that folder and not 5.

Ruby on Rails / PostgreSQL - Library not loaded error when starting server

Heyo. I apologize in advance if this question has been answered in another thread. I've searched through the site but I didn't find an answer. However, the closest related issue was Ruby on Rails / PostgreSQL - Library not Loaded error when starting server- libq.5.dylib, but it was never resolved, and the answer doesn't help me.
I'm trying to get PostgreSQL running on my Mac OSX 10.6.8. I already have Ruby 1.9.3p392 and Rails 3.2.13 installed.
Since I've 10.6.8, and PostGresApp requires 10.7+, I tried installing PG using the manual installer (v9.2.3) available here: http://www.enterprisedb.com/products-services-training/pgdownload
I first installed it to its default path at: /Library/PostgreSQL/9.2/. I then installed the pg gem (PATH=$PATH:/Library/PostgreSQL/9.2/bin sudo gem install pg). When I tried rails s to launch my localhost, I got the error below.
After some reading, I guessed it might be a path error, so I removed the pg gem, and then used the postgresql uninstaller. I then reinstalled pg in /users/stewartmccoy/Library/PostgreSQL/9.2/...and then reinstalled the pg gem. But I still get the same error.
Any thoughts on how I might correctly install PostgreSQL and get my rails server running?
stewart-mccoys-macbook:footy_subs stewartmccoy$ rails s
/Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg.rb:4:in `require': dlopen(/Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle, 9): Library not loaded: libpq.5.dylib (LoadError)
Referenced from: /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle
Reason: image not found - /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg.rb:4:in `<top (required)>'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `each'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `block in require'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `each'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `require'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler.rb:132:in `require'
from /Users/stewartmccoy/Code/footy_subs/config/application.rb:13:in `<top (required)>'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:53:in `require'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:53:in `block in <top (required)>'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
stewart-mccoys-macbook:footy_subs stewartmccoy$ gem uninstall pgSuccessfully uninstalled pg-0.14.1
stewart-mccoys-macbook:footy_subs stewartmccoy$ PATH=$PATH:/users/stewartmccoy/Library/PostgreSQL/9.2/bin sudo gem install pg
Password:
Fetching: pg-0.14.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed pg-0.14.1
1 gem installed
Installing ri documentation for pg-0.14.1...
Installing RDoc documentation for pg-0.14.1...
stewart-mccoys-macbook:footy_subs stewartmccoy$ rails s
/Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg.rb:4:in `require': dlopen(/Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle, 9): Library not loaded: libpq.5.dylib (LoadError)
Referenced from: /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle
Reason: image not found - /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg_ext.bundle
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.14.1/lib/pg.rb:4:in `<top (required)>'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `each'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `block in require'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `each'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `require'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392#global/gems/bundler-1.3.4/lib/bundler.rb:132:in `require'
from /Users/stewartmccoy/Code/footy_subs/config/application.rb:13:in `<top (required)>'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:53:in `require'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:53:in `block in <top (required)>'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
from /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
The key part of the error is:
Library not loaded: libpq.5.dylib (LoadError)
This suggests that ruby can't find libpq at runtime. To address that you should probably set the DYLD_LIBRARY_PATH environment variable to point to the lib directory of your PostgreSQL install, either globally or in a wrapper script you use to start Rails. See this superuser question for some more info.
The Pg gem can find the library during compilation and installation because the pg_config executable is on the PATH and it uses that to find libpq. It appears that it doesn't store the path for use at runtime so you have to set the runtime dynamic linker up yourself.
A simple wrapper script (in case you don't want to modify your global environment) is something like:
#!/bin/bash
export DYLD_LIBRARY_PATH=/path/to/pg/lib
exec rails "$#"
The "$#" basically means "pass all arguments to this script through as if they were passed here directly". It preserves quoting correctly and essentially means that the rails command can't tell you didn't run it directly.
I wanted to put my two cents here to answers above.
Sometimes it's enough to just reinstall pg gem.
gem uninstall pg && gem install pg
In my case I upgraded postgresql server from 9.6 up to 14.x and dylib paths were changed.
/opt/local/lib/postgresql96/libpq.5.dylib -> /opt/local/lib/postgresql14/libpq.5.dylib
The gem uses pg_config to determine paths to /opt/local/lib/postgresql[version] folder (named PKGLIBDIR). To build native library for the gem rake sets paths to dynamic libs by fetching them from pg_config in compile. Once pg gem is compiled the paths are linked forever. So, the reinstallation recompiles and relinks path to the new libraries.
A similar stackoverflow answer proposed removing Postgres.app from your PATH, uninstalling the pg gem, and installing the pg gem again.
(I'm not taking the time to check carefully if that applies to this problem, but it solved a problem I had and I want to spread that solution around since I had trouble finding it.)

ruby on rails mac x os lion run server LoadError

When I type the rails server on terminal, I got the following error.
I don't know how to fix it. Is any one can give me a help?
And I also need a ruby on rails mac os x Lion installation tutorial.
:simple_cms benhuayang$ rails server
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `require':
dlopen(/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from:
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Reason: image not found -
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `<top (required)>' from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0#global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require' from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0#global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require' from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0#global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each' from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0#global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require' from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0#global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each' from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0#global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require' from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0#global/gems/bundler-1.0.21/lib/bundler.rb:122:in `require' from
/Users/benhuayang/Sites/simple_cms/config/application.rb:7:in `<top (required)>' from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/commands.rb:53:in `require' from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/commands.rb:53:in `block in ' from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/commands.rb:50:in `tap' from
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.1/lib/rails/commands.rb:50:in `<top (required)>' from
script/rails:6:in `require' from
script/rails:6:in `<main>'
this is path for mysql
/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0/bin:/Users/benhuayang/.rvm/gems/ruby-1.9.3-p0#global/bin:/Users/benhuayang/.rvm/rubies/ruby-1.9.3-p0/bin:/Users/benhuayang/.rvm/bin:/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
When I've run into this in the past, I've used the following solution.
In the terminal, run:
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib"
Then try running your rails server command in the root of your app. If it works, just put that same command into your ~/.profile so that it runs each time you enter the terminal.
Ryan's solution worked for me when I had the following error after running rake db:migrate, I figured posting it will help with the google search.
rake aborted!
dlopen(/Users/[USERNAME]/.rvm/gems/ruby-1.9.3-p286/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/[USERNAME]/.rvm/gems/ruby-1.9.3-p286/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/[USERNAME]/.rvm/gems/ruby-1.9.3-p286/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
(See full trace by running task with --trace)

Rails server won't run with mysql2 gem

**I know this is a popular issue here, but I just can't seem to get it to run. I've tried just about everything I've read, and the issue persist.
I'm using RVM and 1.9.2. I'm also using MySQL 5.5, and I've reinstalled it several times. My installation of Ruby seems to work well with SQLite, but it chokes on MySQL. I've checked to see if MySQL is working through PHP too, so I know that's not the issue. Rails just can't seem to find the "libmysqlclient.18.dylib" file.
Here's what happens when I run the server:**
littleMac$ sudo rails s
/Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/script_rails_loader.rb:11: warning: Insecure world writable dir /Users/littleMac in PATH, mode 040777
/Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:136: warning: Insecure world writable dir /Users/littleMac in PATH, mode 040777
/Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2.rb:9:in `require': dlopen(/Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2.rb:9:in `<top (required)>'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `block in require'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `require'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'
from /Users/littleMac/sites/TestBox2/config/application.rb:7:in `<top (required)>'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:28:in `require'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:28:in `block in <top (required)>'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
If you are using RVM chances are you don't want to sudo.
Please also format your code in a code block to make it easier for people to help.
Read this post. It seems to be identical.

Resources