Thanks for taking a look at this.
I started a beginner's tutorial on RoR through lynda.com. I followed the instructions to the letter. Everything was working so far until I got to accessing Webrick. When I typed in "rails server" to begin work, I got this error message below.
/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.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/macuser/Sites/simplecms/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'm using a
- iMac
- Ruby 1.87
- Gem 1.7.2
Since I'm not experienced with anything Ruby, I'm lost on how to fix this.
Thanks in advance for your attention and help if possible.
Run these at the terminal:
gem install bundler
bundle
And then you should be able to boot the server.
Edit: You should really look into using rvm to manage your ruby installs and gemsets. It'll save you a lot of time and effort in installing them too.
I ran into the same problem as you (also attempting to go through the Lynda course), and also being a newbie I got pretty frustrated pretty quickly.
Buuuuut, after some searching, I found and answer here I got it to work.
First, I installed the 32-bit version of MySQL, as opposed to the 64-bit version, but I'm not sure if that made a difference.
Then, uninstall the Mysql gem
gem uninstall mysql2
then reinstall it
sudo gem install mysql2
and finally
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
and you should be good to go! Worked for me anyways. good luck!
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
This is the code that worked for me :D
I had the same problem. I simply ran the following code:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib
Press enter, and then run
rails server
and it worked!
Correct way that worked for me was:
cd ~ [command]
nano .bash_profile [command]
add this line of code:
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
ctrl+x [save]
y [yes]
cd Sites/sitename/ [command]
rails server [run WEBrick server]
and you should get this message:
=> Booting WEBrick
=> Rails 3.2.11 application starting in development on localhost:3000
=> Call with -d to detach
来源:https://stackoverflow.com/questions/5690200/ruby-on-rails-3-and-webrick-issue