1

精确地遵循教程并尝试让 rails 服务器运行并收到以下错误:

NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
    Gem.source_index called from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:3.
    NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
    Gem.source_index called from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/source.rb:162.
    NOTE: Gem::SourceIndex#each is deprecated with no replacement. It will be removed on or after 2011-11-01.
    Gem::SourceIndex#each called from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/source.rb:162.
    NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
    Gem.source_index called from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:84.
    /Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
      Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle
      Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2/mysql2.bundle
        from /Library/Ruby/Gems/1.8/gems/mysql2-0.2.11/lib/mysql2.rb:9
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
        from /Library/Ruby/Gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
        from /Users/EricFriedman/Sites/simple_cms/config/application.rb:7
        from /Library/Ruby/Gems/1.8/gems/railties-3.0.8/lib/rails/commands.rb:28:in `require'
        from /Library/Ruby/Gems/1.8/gems/railties-3.0.8/lib/rails/commands.rb:28
        from /Library/Ruby/Gems/1.8/gems/railties-3.0.8/lib/rails/commands.rb:27:in `tap'
        from /Library/Ruby/Gems/1.8/gems/railties-3.0.8/lib/rails/commands.rb:27
        from script/rails:6:in `require'
        from script/rails:6
4

3 回答 3

2

这对我有用:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

这是原始帖子:http ://c.kat.pe/post/how-to-fix-mysql-load-issues-on-mac-os-x/

于 2012-03-29T10:43:18.070 回答
2

如果您使用的是 Rails 3.0.x,则需要锁定您的 mysql2 版本。在您的 Gemfile 中:

gem "mysql2", "~> 0.2.11"

然后运行bundle installbundle update mysql2

编辑

我注意到您使用的是 mysql2 gem 的 0.2.11 版本。

仔细观察,我注意到了这个错误:

未加载库:libmysqlclient.18.dylib (LoadError)

这可能表明 mysql 开发头文件/库不可用。当您运行 mysql2 gem 时,您的安装应该失败bundle install。如果是这样,您需要安装这些开发库,然后重新安装 gem。

于 2011-06-27T19:48:25.953 回答
2
Library not loaded: libmysqlclient.18.dylib (LoadError)

你需要在你的盒子上安装mysql。

如果你输入mysql终端会发生什么?

如果你输入mysql --version终端会发生什么?

于 2011-06-27T19:49:15.437 回答