gpt4 book ai didi

mysql - 尝试使用 mysql2 gem 在 OS X 10.6 上运行 'rails server' 时未加载库 : libmysqlclient. 16.dylib 错误

转载 作者:IT老高 更新时间:2023-10-28 12:48:37 27 4
gpt4 key购买 nike

我已经为此苦苦挣扎了一段时间。

我在我的 Snow Leopard 机器上安装了 Rails 3、gem、mysql。一切都很顺利,直到我创建了我的第一个项目并尝试运行

rails server

运行后我得到:

jontybrook$ rails server
/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2.rb:7
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler.rb:112:in `require'
from /Users/jontybrook/Dropbox/CODING/simple_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
jontybrook$

据我所知,问题出在 mysql2 gem 上。 MySQL 似乎运行良好,我的 Gemfile 引用了 mysql2,我的 database.yml 文件似乎也正常。

错误提示

Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle

还有

jontybrook$ cd /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2
jontybrook$ ls
client.rb em.rb error.rb mysql2.bundle result.rb

MySQL2.bundle 有吗!?

如果我使用旧的 mysql gem,WEBrick 可以正常启动。但这并不理想,不是吗?

我已经尝试了谷歌能给我的一切!非常感谢任何帮助。

最佳答案

我从来没有得到任何对我有用的答案,但这是我用来让它对我有用的命令。这样你就不需要每次更新 mysql 时都使用 install_name_tool

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

关于mysql - 尝试使用 mysql2 gem 在 OS X 10.6 上运行 'rails server' 时未加载库 : libmysqlclient. 16.dylib 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4546698/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com