I'm trying to access my first ruby project. After navigating to the proper directory and typing:
$ rails server
I get the following error message:
/Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2.rb:7:in require': dlopen(/Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
from /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2.rb:7:in'
from /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in require'
from /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:inblock (2 levels) in require'
from /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in each'
from /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:inblock in require'
from /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in each'
from /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:inrequire'
from /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.10/lib/bundler.rb:120:in require'
from /Users/Rozey/Sites/first_project/config/application.rb:7:in'
from /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/commands.rb:28:in require'
from /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/commands.rb:28:inblock in '
from /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/commands.rb:27:in tap'
from /Users/Rozey/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/commands.rb:27:in'
from script/rails:6:in require'
from script/rails:6:in'
I had previously installed the mysql2 gem using RVM. I know there is probably a simple fix but I'm new to this, so I appreciate your help.
Some extra information:
Rozey$ which ruby
/Users/Rozey/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
Rozey$ which mysql
/usr/local/mysql/bin/mysql
Have you had a look at How to fix "dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib"?
It looks like it could be a similar issue
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"
Dropped that in bash.profile and worked like a charm
I tried all of the above and none of it worked. I found this on another page Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem and it worked like a charm:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
Related
I'm running Rails 4.0.3 on Ruby 2.0.0 on Windows 7, and have installed the DevKit (all x64).
I've installed the mysql2 gem using subst X: "C:\Program Files\MySQL\MySQL Server 5.6" and then gem install mysql2 --platform=ruby -- --with-mysql-dir=X:, and it installed fine. I then created a new app with rails new mysql_testy which ran fine, but when I run rails server I get the following error:
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in 'require': 193: %1 is not a valid Win32 application. - C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2/mysql2.so (LoadError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/lib/mysql2.rb:8:in '<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in 'block (2 levels) in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in 'each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in 'block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in 'each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.5.3/lib/bundler.rb:131:in 'require'
from C:/Users/Liam/Ruby/mysql_testy/config/application.rb:7:in '<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:74:in 'require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:74:in 'block in <top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in 'tap'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.3/lib/rails/commands.rb:71:in '<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'`
Do you guys have any idea what's happening?
Not sure if you figured it out yet, but I was having the same issue. I installed the 32 bit sql connector, copied the libmysql.dll file from it and pasted it into Ruby/bin folder. Opened a new command prompt and was able to connect to the server.
Before this step though you may have to reinstall a fresh MySQL2 gem pointing to the path of the connector: gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\mysql-connector-c-6.1.5-win32\lib" --with-mysql-include="C:\mysql-connector\mysql-connector-c-6.1.5-win32\include" --with-mysql-dir="C:\mysql-connector"'
Hope this helps
Installed Rails 3.2.3 and MySQL 5.6 fine on my OSX 10.7.3
I created a new project called "simple_cms" and then, in the terminal, tried to launch webrick with "rails server" and got nothing.
Hideyoshis-MacBook-Pro:simple_CMS gregpfeffer$ rails s
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2.rb:9
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:inrequire'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:inrequire'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:inrequire'
from /Library/Ruby/Gems/1.8/gems/bundler-1.1.3/lib/bundler.rb:119:in require'
from /Users/gregpfeffer/Sites/simple_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:53:inrequire'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:53
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:50:in tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.2.3/lib/rails/commands.rb:50
from script/rails:6:inrequire'
from script/rails:6
Hideyoshis-MacBook-Pro:simple_CMS gregpfeffer$ sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.4/lib/mysql2/mysql2.bundle
install_name_tool: can't open file: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.4/lib/mysql2/mysql2.bundle (No such file or directory)
try adding:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/:$DYLD_LIBRARY_PATH
To your .bash_profile
this assumes you accepted the default installation location for mysql
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2.rb:8
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
from /Users/imran/simple_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
Does anyone know how i can fix this?? Thanks in advance ;-)
now i'm getting this?
dyld: lazy symbol binding failed: Symbol not found:
_mysql_get_client_info Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_get_client_info Referenced from:
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle
Expected in: flat namespace
Trace/BPT trap
may be this post is similiar with your problem :
Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem
Try this:
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"
Put this in your .profile (or .bashrc) and type this command
my_term> source .profile
replace '/usr/local/mysql/lib/' by where you MySQL client is installed
Updated MySQL again from installer (say, mysql-5.5.10-osx10.6-x86_64).
Then MySQL2 gem:
$ sudo gem install mysql2 --
--with-mysql-config=/usr/local/mysql-5.5.10-osx10.6-x86_64/bin/mysql_config
It worked for me.
For permanent fix, try to create a soft link by command -
sudo ln -s /usr/local/mysql/lib/libmysqlclient.16.dylib /usr/lib/libmysqlclient.16.dylib
http://rorguide.blogspot.com/2011/07/getting-error-library-not-loaded.html
I also had this problem and any suggestions I found here or in other questions didn't get me anywhere, but running as root did (with sudo rails s). I guess that when running as root, it uses the right path to the mysql library, but changing it with install_name_tool as described in one of the links here doesn't work, too. As long as I don't find the issue, I need to start my rails app with sudo.
I just compiled ruby and installes rubygems, mysql2 and rails, which worked quite well. But I get the following error message, whenever I try to start the rails server:
/usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `require': dlopen(/usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `block in require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
from /Users/filzo/Documents/rails/blog/config/application.rb:7:in `'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:28:in `require'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:28:in `block in '
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:27:in `tap'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:27:in `'
from script/rails:6:in `require'
from script/rails:6:in `'
I tried several possible solutions (e.g. this: http://railsforum.com/viewtopic.php?pid=23125#23125 with libmysqlclient.18.dylib); but nothing worked for me. I hope you can help me.
EDIT:
It seems like this fixed the problem for me:
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Anyway; is it a bug in the MySQL or the ruby-code?
One of the simple and best way is to create a soft link by command -
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
http://rorguide.blogspot.com/2011/07/getting-error-library-not-loaded.html
This appears to be a known (and unfixed!) bug in the MySQL binary distribution.
Whilst running install_name_tool on your mysql2.bundle files will work, if you remove and rebuild them you're back to square one. Also, you'll have to apply this fix to anything else that links against it. A better solution is to fix the problem in the library itself:
$ sudo install_name_tool -id \
/usr/local/mysql/lib/libmysqlclient.18.dylib \
/usr/local/mysql-5.5.12-osx10.6-x86_64/lib/libmysqlclient.18.dylib
Removing and rebuilding the mysql2 gem:
$ gem uninstall mysql2
$ gem install mysql2
...will pick up the change to the library, and everything should work correctly, without having to tinker with any environment variables.
If you are using RVM (an excellent choice) on Mac OS X - here is the magic command that finally worked for me.
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Users/*USERNAME*/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Replace USERNAME in the syntax appropriately as per your current setup.
And if your version of mysql gem is different change that as well.
A better alternative to install_name tool is to add a path the the mysql lib to your DYLD_LIBRARY_PATH environment variable. In /etc/profile:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib
Or, as I have the Oracle Instant Client installed as well, do:
export ORACLE_HOME="/usr/local/oracle/instantclient_10_2"
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/mysql/lib
Try to make this symbolic link, so rake can find the correct MySQL client lib.
ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
I'm not sure if this will help or not, but I'm using OS X 10.7.1 Lion. In my case, I opened a terminal window, went to /Library/Ruby/Gems/1.8/gems/mysql2-0.3.7 and as soon as I did RVM barked saying it encountered a new or modified .rvmrc file. The contents of that file was:
rvm use 1.9.2#mysql2 --create
It asked if I wanted to trust this .rvmc file. I said yes, and it returned the following:
Using /Users/dan/.rvm/gems/ruby-1.9.2-p290 with gemset mysql2
Once it did, I ran the following command:
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.3.7/lib/mysql2/mysql2.bundle
Once I did, I was set to go. Hope this helps!
I have installed rails and mysql. I have also installed mysql2 gem. I created a rails application by the command
rails new try_cms -d mysql
It was created successfully. But when I try to run the WEBrick server using rails server command I get the following errors.
/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2.rb:7
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/runtime.rb:66:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/runtime.rb:66:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/runtime.rb:55:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/runtime.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler.rb:114:in `require'
from /Users/dilippednekar/Sites/try_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
Thanks in advance.
Try running this (see similar question here)
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Just ran into this problem myself. Make sure you update the version numbers.
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
For some reason the mysql2.bundle file was not in my mysql2 gem. I ran
gem uninstall mysql2
and the gem was uninstalled. Then I immediately ran
sudo gem install mysql2
Then
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Finally rails s launched the server!
I had similar problems. The solutio that worked for me was found here.
If you want something a little less intrusive, just set the DYLD_LIBRARY_PATH environment variable in your MySQL's lib direction.
export DYLD_LIBRARY_PATH=$MYSQL_HOME/lib
I was just hit with this using Rails 3.1.0, ruby-1.9.2-p290 and mysql2 0.3.7. My solution was to downgrade to mysql 2.8.1. Everything looks good so far (I wasn't even able to start the environment).
sudo apt-get install libmysqlclient15-dev libmysqlclient15off libmysql-ruby