mysql +红宝石=噩梦

发布于 2024-08-12 18:18:51 字数 7030 浏览 2 评论 0原文

好吧,我完成了。 我不明白为什么我收到此错误:

rake features

它不能是我无法连接到 mysql 因为:

rake db:migrate

工作完美。

我不断出现此错误:

rake features --trace
(in /Users/myname/Projects/rails_app)
** Invoke features (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment 
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment 
** Execute db:schema:load
rake aborted!
closed stream
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1032:in `sync='
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1032:in `write'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1092:in `finalizer'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:578:in `call'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:578:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:578:in `free'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:438:in `tables'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:24:in `table_exists?'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:106:in `create_table'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:473:in `create_table'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `send'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `method_missing'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:348:in `method_missing'
/Users/myname/Projects/rails_app/db/schema.rb:38
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/schema.rb:43:in `instance_eval'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/schema.rb:43:in `define'
/Users/myname/Projects/rails_app/db/schema.rb:12
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load_without_new_constant_marking'
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load'
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load'
/Users/myname/Projects/rails_app/vendor/rails/railties/lib/tasks/databases.rake:259
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/myname/Projects/rails_app/vendor/rails/railties/lib/tasks/databases.rake:304
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/myname/Projects/rails_app/vendor/rails/railties/lib/tasks/databases.rake:378
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

我的机器: Mac OS X 10.5.8 ruby 1.8.6 (2008-08-11 补丁级别 287) [universal-darwin9.0] 轨道2.3.4 mysql (2.8.1) [rubygem] Mysql路径:/opt/local/lib/mysql5 [通过macport安装]

非常感谢!

Ok, I'm done.
I can't understand why I got this error with:

rake features

It cant' be I can't connect to mysql cause the:

rake db:migrate

works perfectly.

I keep having this error:

rake features --trace
(in /Users/myname/Projects/rails_app)
** Invoke features (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment 
** Execute db:test:purge
** Execute db:test:load
** Invoke db:schema:load (first_time)
** Invoke environment 
** Execute db:schema:load
rake aborted!
closed stream
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1032:in `sync='
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1032:in `write'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1092:in `finalizer'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:578:in `call'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:578:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:578:in `free'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:438:in `tables'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:24:in `table_exists?'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:106:in `create_table'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:473:in `create_table'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `send'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:352:in `method_missing'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:328:in `say_with_time'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/migration.rb:348:in `method_missing'
/Users/myname/Projects/rails_app/db/schema.rb:38
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/schema.rb:43:in `instance_eval'
/Users/myname/Projects/rails_app/vendor/rails/activerecord/lib/active_record/schema.rb:43:in `define'
/Users/myname/Projects/rails_app/db/schema.rb:12
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load_without_new_constant_marking'
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load'
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
/Users/myname/Projects/rails_app/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in `load'
/Users/myname/Projects/rails_app/vendor/rails/railties/lib/tasks/databases.rake:259
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/myname/Projects/rails_app/vendor/rails/railties/lib/tasks/databases.rake:304
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/myname/Projects/rails_app/vendor/rails/railties/lib/tasks/databases.rake:378
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/myname/.gem/ruby/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

My machine:
Mac OS X 10.5.8
ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
Rails 2.3.4
mysql (2.8.1) [rubygem]
Mysql path: /opt/local/lib/mysql5 [installed via macport]

Thank you so much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

十年不长 2024-08-19 18:18:51

保存您的数据库并重新安装 mysql。关注 http://hivelogic.com/articles/compiling-mysql-on-雪豹/ 让我所有的问题都消失了。

Save your DBs and reinstall mysql. Follow http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/ Made all my problems go away.

叫嚣ゝ 2024-08-19 18:18:51

我必须对你的问题进行理论,但没有理由怀疑这两者确实是你的原因,但它们是快速检查。

  1. 您尚未在 config/databases.yml 中正确定义测试数据库

  2. 尝试构建此数据库的 mysql 用户缺乏这样做的权限。

I have to theories about your problem, but no reason to suspect either is really your cause, but they're quick checks.

  1. You haven't properly defined the testing database in config/databases.yml

  2. The mysql user that is attempting to build this database lacks the permission to do so.

何处潇湘 2024-08-19 18:18:51

您可以使用有问题的凭据(database.yml 中的所有内容)连接到有问题的数据库吗?

从命令行“mysql -u your_user -p”?

当您安装 mysql gem 时,它是否正确构建了本机扩展?
当您 gem install mysql --force (重新安装它)时会发生什么?看起来幸福吗?

你以前做过这样的事吗?问题是否可能是缺乏 Rails/mysql 经验或两者兼而有之?还是这顶帽子已经过时了,而你这次只是想不出来?

如果是前者,那么使用 Rails 进行实用敏捷 Web 开发的教程非常好(本书的其余部分也是如此)。

希望那里有帮助。

Can you connect to the database in question with the credentials in question (all the stuff in database.yml)?

"mysql -u your_user -p" from the command line?

When you installed the mysql gem did it properly build the native extensions?
What happens when you gem install mysql --force (to re-install it)? Does it look happy?

Have you ever done this before? Is the problem as likely to be a lack of experience with rails/mysql or both? Or is this old hat and you just can't figure it out this time?

If the former, the tutorial in the pragramatic agile web development with rails is quite good (as is the rest of the book).

Hope something there helps.

无语# 2024-08-19 18:18:51

请告诉输出:

rake db:schema:load RAILS_ENV=test

以确保名为 _test 的现有数据库已配置并在 config/database.yml 下工作

Please tell the output of:

rake db:schema:load RAILS_ENV=test

to be sure that an existing database named _test is configured and working under config/database.yml

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文