库未加载:尝试使用 mysql2 gem 在 OS X 10.6 上运行“rails server"时出现 l

Library not loaded: libmysqlclient.16.dylib error when trying to run #39;rails server#39; on OS X 10.6 with mysql2 gem(库未加载:尝试使用 mysql2 gem 在 OS X 10.6 上运行“rails server时出现 libmysqlclient.16.dylib 错误) - IT屋-程序员软件开发
本文介绍了库未加载:尝试使用 mysql2 gem 在 OS X 10.6 上运行“rails server"时出现 libmysqlclient.16.dylib 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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

I've been struggling with this for some time.

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

I've installed Rails 3, gem, mysql on my Snow Leopard machine. All was going well until I created my first project and tried to run

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 文件似乎也正常.

As far as I can tell the problem is with the mysql2 gem. MySQL seems to be running fine and my Gemfile references mysql2, my database.yml file seems ok also.

错误提到

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 有没有!?

MySQL2.bundle is there!?

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

If I use the old mysql gem, WEBrick boots fine. But that's not ideal, is it?

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

I've tried everything google can give me! Any help much appreciated.

推荐答案

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

I was never able to get any of these answers to work for me, but this is the command that I used to make it work for me. This way you don't need to use install_name_tool every time you update your mysql

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

这篇关于库未加载:尝试使用 mysql2 gem 在 OS X 10.6 上运行“rails server"时出现 libmysqlclient.16.dylib 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Simulating MySQL#39;s ORDER BY FIELD() in Postgresql(在 Postgresql 中模拟 MySQL 的 ORDER BY FIELD())
Using MySQL query to traverse rows to make a recursive tree(使用MySQL查询遍历行制作递归树)
MySQL LOAD DATA INFILE with ON DUPLICATE KEY UPDATE(MySQL LOAD DATA INFILE 和 ON DUPLICATE KEY UPDATE)
Search for quot;whole word matchquot; in MySQL(搜索“全字匹配在 MySQL 中)
add column to mysql table if it does not exist(如果不存在,则将列添加到 mysql 表)
MIN/MAX vs ORDER BY and LIMIT(MIN/MAX 与 ORDER BY 和 LIMIT)