Trying to learn ruby on rails here and following a video tutorial but can't seem to get the enviornment to run. I'm at the point where I have created a project using rails new project_name but then, when I go to run the server, rails server, I can't actually get it to work.
The message I get follows:
drew$ rails server
/usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.7/lib/mysql2.rb:9:in `require': dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.7/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
Referenced from: /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.7/lib/mysql2/mysql2.bundle
Reason: image not found - /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.7/lib/mysql2/mysql2.bundle
from /usr/local/lib/ruby/gems/1.9.1/gems/mysql2-0.3.7/lib/mysql2.rb:9:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `block in require'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.18/lib/bundler.rb:120:in `require'
from /Users/andrewdellostritto/Sites/simple_cms/config/application.rb:7:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:52:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:52:in `block in <top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:49:in `tap'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:49:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Can anyone help? Thanks in advance!
It looks like your mysql2 gem isn't properly installed. Take a look at this question . Not sure what your environment is like but if you are on windows take a look at the second answer. I think that is the one that will apply to you.
libmysqlclient.18.dylib
in not your PATH. You need to add the mysql lib directory to the environment variable: DYLD_LIBRARY_PATH
(Mac OS X) or LD_LIBRARY_PATH
(Linux).
Say your mysql is installed in /usr/local/mysql/
, do the following:
# Linux
export LD_LIBRARY_PATH="/usr/local/mysql/lib/:$LD_LIBRARY_PATH"
# Mac OS X
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib/:$DYLD_LIBRARY_PATH"
可能是您没有正确安装mysql或检查您的ruby版本是否支持rails版本.....
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.