Ruby:mysql2-Gem 不工作(Mac OS X Snow Leopard,Ruby 1.9.2)

Ruby: mysql2-Gem not working (Mac OS X Snow Leopard, Ruby 1.9.2)(Ruby:mysql2-Gem 不工作(Mac OS X Snow Leopard,Ruby 1.9.2))
本文介绍了Ruby:mysql2-Gem 不工作(Mac OS X Snow Leopard,Ruby 1.9.2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚编译了 ruby​​ 并安装了 ruby​​gems、mysql2 和 rails,效果很好.但是,每当我尝试启动 rails 服务器时,都会收到以下错误消息:

<上一页>/usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `require': dlopen(/usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): 库未加载: libmysqlclient.18.dylib (LoadError)引用自:/usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle原因:找不到图像 -/usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle来自/usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `'来自/usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'来自/usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `block (2 levels) in require'来自/usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'来自/usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `block in require'来自/usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'来自/usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'来自/usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'来自/Users/filzo/Documents/rails/blog/config/application.rb:7:in `'来自/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:28:in `require'来自/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:28:in `block in'来自/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:27:in `tap'来自/usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:27:in `'来自脚本/rails:6:in `require'来自脚本/rails:6:in `'

我尝试了几种可能的解决方案(例如:http://railsforum.com/viewtopic.php?pid=23125#23125 与 libmysqlclient.18.dylib);但没有什么对我有用.我希望你能帮助我.

看来这解决了我的问题:

sudo install_name_tool -change libmysqlclient.18.dylib/usr/local/mysql/lib/libmysqlclient.18.dylib/usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle

无论如何;是 MySQL 还是 ruby​​ 代码中的错误?

解决方案

最简单最好的方法之一是通过命令创建软链接 -

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

http://rorguide.blogspot.com/2011/07/getting-error-library-not-loaded.html

I just compiled ruby and installes rubygems, mysql2 and rails, which worked quite well. But I get the following error message, whenever I try to start the rails server:

/usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `require': dlopen(/usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
  Referenced from: /usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
  Reason: image not found - /usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
  from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `'
  from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
  from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
  from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
  from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `block in require'
  from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
  from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
  from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
  from /Users/filzo/Documents/rails/blog/config/application.rb:7:in `'
  from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:28:in `require'
  from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:28:in `block in '
  from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:27:in `tap'
  from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.5/lib/rails/commands.rb:27:in `'
  from script/rails:6:in `require'
  from script/rails:6:in `'

I tried several possible solutions (e.g. this: http://railsforum.com/viewtopic.php?pid=23125#23125 with libmysqlclient.18.dylib); but nothing worked for me. I hope you can help me.

EDIT: It seems like this fixed the problem for me:

sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/ruby/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle 

Anyway; is it a bug in the MySQL or the ruby-code?

解决方案

One of the simple and best way is to create a soft link by command -

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

http://rorguide.blogspot.com/2011/07/getting-error-library-not-loaded.html

这篇关于Ruby:mysql2-Gem 不工作(Mac OS X Snow Leopard,Ruby 1.9.2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)