2011-11-02 90 views
0
 
Derek-MacBook-Pro:example derek$ rails g 
/Library/Ruby/Gems/1.8/gems/mysql2-0.3.7/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.3.7/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError) 
    Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.3.7/lib/mysql2/mysql2.bundle 
    Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.3.7/lib/mysql2/mysql2.bundle 
    from /Library/Ruby/Gems/1.8/gems/mysql2-0.3.7/lib/mysql2.rb:9 
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler/runtime.rb:68:in `require' 
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler/runtime.rb:68:in `require' 
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler/runtime.rb:66:in `each' 
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler/runtime.rb:66:in `require' 
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler/runtime.rb:55:in `each' 
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler/runtime.rb:55:in `require' 
    from /Library/Ruby/Gems/1.8/gems/bundler-1.0.11/lib/bundler.rb:120:in `require' 
    from /Users/derek/example/config/application.rb:7 
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.10/lib/rails/commands.rb:15:in `require' 
    from /Library/Ruby/Gems/1.8/gems/railties-3.0.10/lib/rails/commands.rb:15 
    from script/rails:6:in `require' 
    from script/rails:6 

我安裝了MySQL並在OS X Lion中運行。我安裝了寶石。它出現在gem列表(版本0.3.7)中。哪裏不對?Rails 3:MySQL2 gem「庫未加載」

編輯:

在這裏,我將添加我的database.yml文件。它說適配器在每種環境類型中都是mysql2。也許這將幫助:

# MySQL. Versions 4.1 and 5.0 are recommended. 
# 
# Install the MySQL driver: 
# gem install mysql2 
# 
# And be sure to use new-style password hashing: 
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html 
development: 
    adapter: mysql2 
    encoding: utf8 
    reconnect: false 
    database: example_development 
    pool: 5 
    username: root 
    password: 
    host: localhost 

# Warning: The database defined as "test" will be erased and 
# re-generated from your development database when you run "rake". 
# Do not set this db to the same as development or production. 
test: 
    adapter: mysql2 
    encoding: utf8 
    reconnect: false 
    database: example_test 
    pool: 5 
    username: root 
    password: 
    host: localhost 

production: 
    adapter: mysql2 
    encoding: utf8 
    reconnect: false 
    database: example_production 
    pool: 5 
    username: root 
    password: 
    host: localhost 

回答

0
  • 確保「mysql2」是你的database.yml中指定的數據庫適配器
  • 確保「mysql2」在你的Gemfile
指定的寶石

我記得那兩個缺失的東西中的一個錯誤實際上是不直觀的,聽起來像是在描述另一個...所以,只要確保兩者都是正確的:-)

+0

我更新了我的問題與database.yml – Derek

+0

試試'bundle exec rails g' –

+0

Gah,我剛剛注意到/意識到缺少的庫不是gem而是mysql lib。你在哪個平臺上? –

相關問題