使用 rvm 在 Snow Leopard for Rails 3 上安装 mysql2 gem [英] Install mysql2 gem on Snow Leopard for Rails 3 with rvm

查看:46
本文介绍了使用 rvm 在 Snow Leopard for Rails 3 上安装 mysql2 gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近升级到 Rails 3 并使用 Rails 3.0.3 创建了一个新应用程序,但我一直收到错误

<前>Macintosh:$ rails 服务器=> 启动 WEBrick=> Rails 3.0.3 应用程序在 http://0.0.0.0:3000 上开始开发=> 用 -d 调用来分离=> Ctrl-C 关闭服务器[2010-11-28 11:32:47] INFO WEBrick 1.3.1[2010-11-28 11:32:47] INFO ruby​​ 1.8.7 (2010-04-19) [i686-darwin10.4.0][2010-11-28 11:32:47] 信息 WEBrick::HTTPServer#start: pid=1055 port=30002010 年 11 月 28 日星期日 11:32:52 +0000 开始为 127.0.0.1 获取/"RuntimeError (!!! 缺少 mysql2 gem.将它添加到您的 Gemfile: gem 'mysql2'):

我有一台 64 位机器.错误仅在文档中,看起来 gem 安装正确.

<前>Macintosh:$ env ARCHFLAGS="-arch i386" gem install mysql2 --with-mysql-config=/usr/local/mysql/bin/mysql_config构建原生扩展.这可能需要一段时间...成功安装mysql2-0.2.6安装了 1 个宝石为 mysql2-0.2.6 安装 ri 文档...封闭类/模块'mMysql2'为类客户端未知为 mysql2-0.2.6 构建 YARD (yri) 索引...为 mysql2-0.2.6 安装 RDoc 文档...封闭类/模块'mMysql2'为类客户端未知

我已经在我的 GemFile 中添加了 gem

<前>来源'http://rubygems.org'宝石导轨",3.0.3"宝石'mysql2'gem 'sqlite3-ruby', :require => 'sqlite3'

我的 GemFile.lock 看起来像这样

<前>宝石远程:http://rubygems.org/眼镜:摘要 (1.0.0)actionmailer (3.0.3)动作包(= 3.0.3)邮件 (~> 2.2.9)动作包 (3.0.3)活动模型(= 3.0.3)主动支持(= 3.0.3)建设者(〜> 2.1.2)erubis (~> 2.6.6)i18n (~> 0.4)机架 (~> 1.2.1)机架安装(~> 0.6.13)机架测试(~> 0.5.6)tzinfo (~> 0.3.23)活动模型 (3.0.3)主动支持(= 3.0.3)建设者(〜> 2.1.2)i18n (~> 0.4)活动记录 (3.0.3)活动模型(= 3.0.3)主动支持(= 3.0.3)海尔 (~> 2.0.2)tzinfo (~> 0.3.23)活动资​​源 (3.0.3)活动模型(= 3.0.3)主动支持(= 3.0.3)主动支持 (3.0.3)海尔 (2.0.4)建造者 (2.1.2)erubis (2.6.6)摘要 (>= 1.0.0)i18n (0.4.1)邮件 (2.2.10)主动支持 (>= 2.3.6)i18n (~> 0.4.1)哑剧类型(~> 1.16)树梢 (~> 1.4.8)哑剧类型 (1.16)mysql2 (0.2.6)多语言 (0.3.1)机架 (1.2.1)机架安装 (0.6.13)机架 (>= 1.0.0)机架测试 (0.5.6)机架 (>= 1.0)导轨 (3.0.3)actionmailer (= 3.0.3)动作包(= 3.0.3)活动记录(= 3.0.3)活动资​​源 (= 3.0.3)主动支持(= 3.0.3)捆绑器 (~> 1.0)栏杆 (= 3.0.3)栏杆 (3.0.3)动作包(= 3.0.3)主动支持(= 3.0.3)耙子 (>= 0.8.7)雷神 (~> 0.14.4)耙子 (0.8.7)sqlite3-ruby (1.2.4)雷神 (0.14.6)树梢 (1.4.9)多语言 (>= 0.3.1)tzinfo (0.3.23)平台红宝石依赖mysql2导轨 (= 3.0.3)sqlite3-ruby

宝石列表

<前>Macintosh:$ gem list*** 当地宝石 ***摘要 (1.0.0)actionmailer (3.0.3)动作包 (3.0.3)活动模型 (3.0.3)活动记录 (3.0.3)活动资​​源 (3.0.3)主动支持 (3.0.3)act_as_ferret (0.4.4)海尔 (2.0.4)建造者 (3.0.0, 2.1.2)捆绑器 (1.0.7)卡皮斯特拉诺 (2.5.9)dnssd (1.3)erubis (2.6.6)快速线程 (1.0.7)gnuplot (2.2)高线 (1.6.1, 1.5.1)hpricot (0.8.1)i18n (0.4.2, 0.4.1)libxml-ruby (1.1.3)线缓存 (0.43)邮件 (2.2.10)内存缓存客户端(1.8.5、1.7.6)内存缓存 (0.17.5)哑剧类型 (1.16)mysql2 (0.2.6)网络 scp (1.0.4, 1.0.2)网络 sftp (2.0.5, 2.0.2)网络 ssh (2.0.23, 2.0.15)网络 ssh 网关 (1.0.1)多语言 (0.3.1)机架(1.2.1、1.0.1、1.0.0)机架安装 (0.6.13)机架测试 (0.5.6)导轨 (3.0.3)栏杆 (3.0.3)耙子 (0.8.7, 0.8.4)rcov (0.9.9, 0.9.8)文档 (2.5.11)红布 (4.2.2)rmagick (2.12.2)ruby-debug-base (0.10.3)ruby-debug-ide (0.4.5)rubygems 更新(1.3.7、1.3.5、1.3.3)房车 (1.1.1)sqlite3-ruby (1.3.2, 1.2.4)测试规范 (0.10.0)文本格式 (1.0.0)文本连字符 (1.0.0)雷神 (0.14.6)树梢 (1.4.9)tzinfo (0.3.23)码 (0.5.8)

Mysql 已启动并正在运行:

<前>Macintosh:$ mysql -uroot欢迎使用 MySQL 监视器.命令以 ; 结尾或\g.您的 MySQL 连接 ID 为 1服务器版本:5.1.53 MySQL 社区服务器 (GPL)版权所有 (c) 2000、2010,Oracle 和/或其附属公司.版权所有.本软件不附带任何保证.这是免费软件,欢迎您在 GPL v2 许可下修改和重新分发它输入帮助;"或 '\h' 寻求帮助.键入 '\c' 清除当前输入语句.mysql>

这就是我在全新应用程序中的全部内容,但我仍然遇到缺少 mysql2 gem 的问题.

我有安装了 X Code 3.2.4 的 Snow Leopard 10.6.5.

有什么想法吗?

提前致谢!

解决方案

我实际上在我的 database.yml 上设置了错误的适配器

所以修复是

<前>发展:适配器:mysql2数据库: development_database用户名:root密码:

代替

<前>适配器:mysql

呸!

I have recently upgraded to Rails 3 and created a new application with Rails 3.0.3, but I keep getting an error

Macintosh:$ rails server
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-11-28 11:32:47] INFO  WEBrick 1.3.1
[2010-11-28 11:32:47] INFO  ruby 1.8.7 (2010-04-19) [i686-darwin10.4.0]
[2010-11-28 11:32:47] INFO  WEBrick::HTTPServer#start: pid=1055 port=3000


Started GET "/" for 127.0.0.1 at Sun Nov 28 11:32:52 +0000 2010

RuntimeError (!!! Missing the mysql2 gem. Add it to your Gemfile: gem 'mysql2'):


I have a 64 bits machine. Errors are only on documentation and looked like the gem was installed correctly.

Macintosh:$ env ARCHFLAGS="-arch i386" gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions.  This could take a while...
Successfully installed mysql2-0.2.6
1 gem installed
Installing ri documentation for mysql2-0.2.6...
Enclosing class/module 'mMysql2' for class Client not known
Building YARD (yri) index for mysql2-0.2.6...
Installing RDoc documentation for mysql2-0.2.6...
Enclosing class/module 'mMysql2' for class Client not known

I have added the gem in my GemFile

source 'http://rubygems.org'

gem 'rails', '3.0.3'
gem 'mysql2'
gem 'sqlite3-ruby', :require => 'sqlite3'

My GemFile.lock looks like this

GEM
  remote: http://rubygems.org/
  specs:
    abstract (1.0.0)
    actionmailer (3.0.3)
      actionpack (= 3.0.3)
      mail (~> 2.2.9)
    actionpack (3.0.3)
      activemodel (= 3.0.3)
      activesupport (= 3.0.3)
      builder (~> 2.1.2)
      erubis (~> 2.6.6)
      i18n (~> 0.4)
      rack (~> 1.2.1)
      rack-mount (~> 0.6.13)
      rack-test (~> 0.5.6)
      tzinfo (~> 0.3.23)
    activemodel (3.0.3)
      activesupport (= 3.0.3)
      builder (~> 2.1.2)
      i18n (~> 0.4)
    activerecord (3.0.3)
      activemodel (= 3.0.3)
      activesupport (= 3.0.3)
      arel (~> 2.0.2)
      tzinfo (~> 0.3.23)
    activeresource (3.0.3)
      activemodel (= 3.0.3)
      activesupport (= 3.0.3)
    activesupport (3.0.3)
    arel (2.0.4)
    builder (2.1.2)
    erubis (2.6.6)
      abstract (>= 1.0.0)
    i18n (0.4.1)
    mail (2.2.10)
      activesupport (>= 2.3.6)
      i18n (~> 0.4.1)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.16)
    mysql2 (0.2.6)
    polyglot (0.3.1)
    rack (1.2.1)
    rack-mount (0.6.13)
      rack (>= 1.0.0)
    rack-test (0.5.6)
      rack (>= 1.0)
    rails (3.0.3)
      actionmailer (= 3.0.3)
      actionpack (= 3.0.3)
      activerecord (= 3.0.3)
      activeresource (= 3.0.3)
      activesupport (= 3.0.3)
      bundler (~> 1.0)
      railties (= 3.0.3)
    railties (3.0.3)
      actionpack (= 3.0.3)
      activesupport (= 3.0.3)
      rake (>= 0.8.7)
      thor (~> 0.14.4)
    rake (0.8.7)
    sqlite3-ruby (1.2.4)
    thor (0.14.6)
    treetop (1.4.9)
      polyglot (>= 0.3.1)
    tzinfo (0.3.23)

PLATFORMS
  ruby

DEPENDENCIES
  mysql2
  rails (= 3.0.3)
  sqlite3-ruby

Gem list

Macintosh:$ gem list

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.3)
actionpack (3.0.3)
activemodel (3.0.3)
activerecord (3.0.3)
activeresource (3.0.3)
activesupport (3.0.3)
acts_as_ferret (0.4.4)
arel (2.0.4)
builder (3.0.0, 2.1.2)
bundler (1.0.7)
capistrano (2.5.9)
dnssd (1.3)
erubis (2.6.6)
fastthread (1.0.7)
gnuplot (2.2)
highline (1.6.1, 1.5.1)
hpricot (0.8.1)
i18n (0.4.2, 0.4.1)
libxml-ruby (1.1.3)
linecache (0.43)
mail (2.2.10)
memcache-client (1.8.5, 1.7.6)
memcached (0.17.5)
mime-types (1.16)
mysql2 (0.2.6)
net-scp (1.0.4, 1.0.2)
net-sftp (2.0.5, 2.0.2)
net-ssh (2.0.23, 2.0.15)
net-ssh-gateway (1.0.1)
polyglot (0.3.1)
rack (1.2.1, 1.0.1, 1.0.0)
rack-mount (0.6.13)
rack-test (0.5.6)
rails (3.0.3)
railties (3.0.3)
rake (0.8.7, 0.8.4)
rcov (0.9.9, 0.9.8)
rdoc (2.5.11)
RedCloth (4.2.2)
rmagick (2.12.2)
ruby-debug-base (0.10.3)
ruby-debug-ide (0.4.5)
rubygems-update (1.3.7, 1.3.5, 1.3.3)
rvm (1.1.1)
sqlite3-ruby (1.3.2, 1.2.4)
test-spec (0.10.0)
text-format (1.0.0)
text-hyphen (1.0.0)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.23)
yard (0.5.8)

My Mysql is up and running:

Macintosh:$ mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.53 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

This is all I have in my brand new application, but I'm still getting the missing mysql2 gem problem.

I have Snow Leopard 10.6.5 with X Code 3.2.4 installed.

Any idea?

Thanks in advance!

解决方案

I actually had the wrong adaptor set on my database.yml

So the fix is

development:
  adapter: mysql2
  database: development_database
  username: root
  password:

Instead of

adapter: mysql

Doh!

这篇关于使用 rvm 在 Snow Leopard for Rails 3 上安装 mysql2 gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆