0

我正在学习 Michael Hartl 的 Rails 教程,但在演示应用程序的最后阶段遇到了一些问题,即在 Heroku 上运行 rake 命令将数据库迁移到 Web。

带有 --trace 的 rake 命令给出以下结果:

$ heroku run rake db:migrate --trace
Running `rake db:migrate --trace` attached to terminal...
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36: command not found: tput cols
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36: command not found: tput lines
up, run.1
(in /app)
* Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
no such file to load -- pg
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `block in require'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:227:in `load_dependency'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:9:in `postgresql_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `new_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:238:in `checkout_new_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:194:in `block (2 levels) in checkout'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `loop'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:190:in `block in checkout'
/usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:189:in `checkout'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in `connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:318:in `retrieve_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:97:in `retrieve_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/migration.rb:486:in `initialize'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/migration.rb:433:in `new'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/migration.rb:433:in `up'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/migration.rb:415:in `migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.0.1/lib/active_record/railties/databases.rake:142:in `block (2 levels) in <top (required)>'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in `block in execute'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:597:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in `block (2 levels) in top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in `block in top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2001:in `block in run'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/app/vendor/bundle/ruby/1.9.1/gems/rake-0.8.7/bin/rake:31:in `<top (required)>'
/app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `load'
/app/vendor/bundle/ruby/1.9.1/bin/rake:19:in `<main>'

我认为开头的“找不到命令:tput”的东西可能是我修改过的东西(看起来像“输出”这个词被切断了)所以我从头开始重做了整个章节,但最终结果相同,所以我不认为这是我对代码所做的任何更改。

我使用的是 Windows PC,运行 XP。在本地主机上运行时一切正常,并且我的 Git 存储库完美地推送到 Heroku,所以除了这个 rake 命令之外一切正常。如果您想查看任何其他文件,请访问:https ://github.com/jimbobsweeney/demo_app

我非常感谢您对此提供的任何帮助。它正在融化我的大脑。

4

1 回答 1

1

你有安装 Cygwin 吗?这篇文章 (日文)提到了这个错误并指出了这个 SO question,它建议您确保安装了 Cygwin 和可能的 ncurses。那里的评论链接到这篇文章,它也可能有有用的信息。

看起来问题是heroku正在tput你的shell中寻找不可用的命令(我相信它是ncurses附带的)

至于堆栈跟踪,看起来pggem 不在您Gemfile的生产环境将执行它的地方。不必为了pg让部署工作而在 Windows 上安装。为此:production在您的组中创建一个组。Gemfile

group :production do
  gem "pg", "~> 0.11.0"
end

您可以在bundler 文档中了解有关组的更多信息。

于 2012-07-09T23:25:11.060 回答