Rails服务器不会与mysql2 gem一起运行

时间:2011-08-04 16:33:07

标签: ruby-on-rails

**我知道这是一个很受欢迎的问题,但我似乎无法让它运行起来。我已经尝试了所有我读过的内容,问题仍然存在。

我正在使用RVM和1.9.2。我也使用MySQL 5.5,我已经多次重新安装它。我的Ruby安装似乎与SQLite一起使用,但它在MySQL上窒息。我已经检查过MySQL是否也在使用PHP,所以我知道这不是问题。 Rails似乎无法找到“libmysqlclient.18.dylib”文件。

以下是我运行服务器时会发生什么:**

littleMac$ sudo rails s
/Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/script_rails_loader.rb:11: warning: Insecure world writable dir /Users/littleMac in PATH, mode 040777
/Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:136: warning: Insecure world writable dir /Users/littleMac in PATH, mode 040777
/Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2.rb:9:in `require': dlopen(/Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle
  Reason: image not found - /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle
    from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/mysql2-0.2.11/lib/mysql2.rb:9:in `<top (required)>'
    from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `require'
    from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `each'
    from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `each'
    from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:55:in `require'
    from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler.rb:120:in `require'
    from /Users/littleMac/sites/TestBox2/config/application.rb:7:in `<top (required)>'
    from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:28:in `require'
    from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:28:in `block in <top (required)>'
    from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
    from /Users/littleMac/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

1 个答案:

答案 0 :(得分:0)

如果您正在使用RVM,则不希望sudo

还请在代码块中格式化代码,以便人们更方便地提供帮助。

阅读this post。它似乎完全相同。