Going through the Lynda training for Ruby on Rails and got to the point where I am starting the WEBrick sever via the rails s command. I am in the same directory as the video /Users/myuser/Sites/simple_cms
I get the following error:
/usr/local/lib/ruby/gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle: dlopen(/usr/local/lib/ruby/gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Reason: image not found - /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
from /usr/local/lib/ruby/gems/1.8/gems/mysql2-0.3.2/lib/mysql2.rb:8
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in `each'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler.rb:120:in `require'
from /Users/myuser/Sites/simple_cms/config/application.rb:7
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
I followed the instructions # Unable to start rails server
Still getting the error. I also followed the directions # rails server fails to start with mysql2 using rvm & ruby 1.9.2-p0 on OSX 10.6.5
Any help would be appreciated.
Okay so after further research I found my own answer
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib
This did it for me. Just incase anyone else can't move past this problem with the original solutions.
Source: http://samuel.kadolph.com/2011/04/mysql2-gem-and-mac-os-x-image-not-found/
Related
I'm new to RoR and I can't seem to get WEBrick up and listening. Here is the console output. I use Mountain Lion, Rails 3.2.8 and Ruby 1.9.3. Help please
/Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `require': dlopen(/Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
from /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2.rb:9:in `<top (required)>'
from /Users/Adham/.rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `require'
from /Users/Adham/.rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/Adham/.rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `each'
from /Users/Adham/.rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `block in require'
from /Users/Adham/.rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `each'
from /Users/Adham/.rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `require'
from /Users/Adham/.rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.2.0/lib/bundler.rb:128:in `require'
from /Users/Adham/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
from /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
from /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
from /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
from /Users/Adham/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
the answer is here:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
rails + MySQL on OSX: Library not loaded: libmysqlclient.18.dylib
--- EDITED
Your $DYLD_LIBRARY_PATH does not contains /usr/local/mysql/lib directory, so there are 2 solution
symlink
add /usr/local/mysql/lib to $DYLD_LIBRARY_PATH in .bashrc or somewhere
Don't know if this answer is helpful or not ... but I ran into the same problem of sorts this week.
When I googled around for an answer, the one that I found helpful was just to put gem 'thin' in Gemfile.
(of course, this is reliant on having installed the thin gem already)
Then run bundle install after that. (this installs the thin gem).
When you run rails server, it'll work with thin automatically.
Hope this helps!
edit: changed bundle to bundle install
edit 2: added the sentence about thin gem
It looks like your mysql2 gem is not properly installed. Take a look at the answer to this question. It should help you set it up. You need to first install mysql (I like using homebrew to do this). Then gem install with the proper path.
Ruby gem mysql2 install failing
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.
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)
I have tried various installation methods for deploying a WEBrick and mongrel from the terminal. When I enter the rails server command I get the following:
Toran1$ rails server
/Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2.rb:8:in `require': dlopen(/Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/mysql2-0.3.2/lib/mysql2.rb:8:in `<top (required)>'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in `require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in `each'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:66:in `block in require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in `each'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler/runtime.rb:55:in `require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.13/lib/bundler.rb:120:in `require'
from /Users/Toran1/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/commands.rb:28:in `block in <top (required)>'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /Users/Toran1/.rvm/gems/ruby-1.9.2-head/gems/railties-3.0.7/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have installed the gem both locally and at the root level, and I also have navigated to the application folder before issuing the command. Any help would be appreciated!
Webrick will install automatically if you install rails in a correct manner.
Try this link
Here
And if you don't want to install rails again, try to install server using gem command
Dont forget to include the gems in Gemfile and to run "bundle install"
If you are using Rails < 3.1 you need to use version ~> 0.2.7 of the mysql2 gem
Checkout the documentation and search for active record: https://github.com/brianmario/mysql2
I'm not sure if that will help solve this problem directly, but it may solve others that you may encounter.
Just update your bundler, maybe of any-one of the older gem is conflicting with latest one, this type of issues arises.
gem install bundler
and then bundler install
If you find again error, then delete GEM.lock file, then run
bundler install
This may resolve the issue.
When i tried rails server I got:
/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler/runtime.rb:66:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler/runtime.rb:66:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler/runtime.rb:55:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler/runtime.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler.rb:120:in `require'
from /Users/inathan/sites/simple_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.6/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
I thought I followed the steps verbatim, but now I'm stumped. Thanks in advance...
You need to install mysql from mysql official site, make sure it is started and then install appropriate mysql gem (mysql for rails 2.x and mysql2 for rails 3.x)