无法运行WEBrick

时间:2011-09-21 04:34:03

标签: mysql ruby-on-rails

尝试在轨道上学习ruby并遵循视频教程,但似乎无法让环境运行。我正处于使用rails new project_name创建项目的那一点,但是当我去运行服务器时,使用rails服务器,我实际上无法让它工作。

我得到的信息如下:

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>'

有人可以帮忙吗?提前谢谢!

3 个答案:

答案 0 :(得分:2)

看起来你的mysql2 gem没有正确安装。 Take a look at this question。不确定你的环境是什么样的,但如果你在Windows上,请看第二个答案。我认为这是适用于你的那个。

答案 1 :(得分:1)

libmysqlclient.18.dylib不在您的路径中。您需要将mysql lib目录添加到环境变量:DYLD_LIBRARY_PATH(Mac OS X)或 LD_LIBRARY_PATH(Linux)。

假设您的mysql已安装在/usr/local/mysql/中,请执行以下操作:

# 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"

答案 2 :(得分:0)

可能是你没有正确安装mysql或检查你的ruby版本是否支持rails版本.....