Rails、MySQL 和雪豹

我使用我们在 WWDC 获得的光盘升级到 Snow Leopard.

尝试运行我的一些 rails 应用程序现在抱怨 sql

(在/Users/coneybeare/Projects/Ambiance/ambiance-server 中)!!!捆绑的 mysql.rb 驱动程序已从 Rails 2.2 中删除.请安装 mysql gem 并重试:gem install mysql.导入/Users/coneybeare/Projects/Ambiance/ambiance-sounds/Import 32/Compressed/中的所有声音-- AdirondackPeepers.caf!!!捆绑的 mysql.rb 驱动程序已从 Rails 2.2 中删除.请安装 mysql gem 并重试:gem install mysql.耙子中止!dlopen(/opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): 库未加载:/usr/local/mysql/lib/libmysqlclient.16.dylib引用自:/opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle原因:找不到图像 -/opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle(通过使用 --trace 运行任务查看完整跟踪)

我可以发誓我以前解决过这个问题.问题是

sudo gem 安装 mysql

不起作用并给出错误:

 构建原生扩展.这可能需要一段时间...错误:安装mysql时出错:错误:无法构建 gem 本机扩展./opt/local/bin/ruby extconf.rb 安装mysql在 -lmysqlclient 中检查 mysql_query()... 否检查 -lm 中的 main() ... 是的在 -lmysqlclient 中检查 mysql_query()... 否检查 -lz 中的 main() ... 是的在 -lmysqlclient 中检查 mysql_query()... 否检查 -lsocket 中的 main()... 否在 -lmysqlclient 中检查 mysql_query()... 否检查 -lnsl 中的 main()... 否在 -lmysqlclient 中检查 mysql_query()... 否Gem 文件将保留安装在/opt/local/lib/ruby/gems/1.8/gems/mysql-2.7 中以供检查.结果记录到/opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

有没有人让mysql在雪豹上使用rails?如果是这样,您的设置是什么?更好的是,我可以做些什么来重现它?

解决方案

我刚刚经历了同样的痛苦......这对我有用:

  1. 从 mysql.com 下载/安装 64 位 MySQL 5.1.37
  2. 运行以下命令:

<前>须藤宝石更新--系统sudo env ARCHFLAGS="-arch x86_64" gem install mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config

我还卸载了从我的 10.5 天开始漂浮的所有 mysql gem,如果上述方法对您不起作用,则可能会这样做:)

I upgraded to Snow Leopard using the disc we got at WWDC.

Trying to run some of my rails apps now complains about sql

    (in /Users/coneybeare/Projects/Ambiance/ambiance-server)
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
Importing all sounds in /Users/coneybeare/Projects/Ambiance/ambiance-sounds/Import 32/Compressed/

 -- AdirondackPeepers.caf
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
dlopen(/opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): Library not loaded: /usr/local/mysql/lib/libmysqlclient.16.dylib
  Referenced from: /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle
  Reason: image not found - /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle

(See full trace by running task with --trace)

I could have sworn I fixed this once before. The problem is that

sudo gem install mysql

does not work and gives the error:

 Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

/opt/local/bin/ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no


Gem files will remain installed in /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

Has anybody gotten mysql to work with rails on snow leopard yet? If so, what is your setup and better yet, what can I do to reproduce it?

解决方案

I just went through the same pain... here's what worked for me:

  1. Download / install the 64-bit MySQL 5.1.37 from mysql.com
  2. run the following commands:


    sudo gem update --system

    sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

I also uninstalled all mysql gems that were floating around from my 10.5 days, that may do it if the above doesn't work for you :)

相关文章