如何解决如何修复Heroku上未初始化的常量Rake :: DSL问题?
| 除了在Heroku上发生我的错误之外,我得到的错误类似于这些问题中的错误:2011-05-30T09:03:29+00:00 heroku[worker.1]: Starting process with command: `rake jobs:work`
2011-05-30T09:03:30+00:00 app[worker.1]: (in /app)
2011-05-30T09:03:30+00:00 heroku[worker.1]: State changed from starting to up
2011-05-30T09:03:33+00:00 app[worker.1]: rake aborted!
2011-05-30T09:03:33+00:00 app[worker.1]: uninitialized constant Rake::DSL
2011-05-30T09:03:33+00:00 app[worker.1]: /app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.0/lib/rake/tasklib.rb:8:in `<class:TaskLib>\'
这些问题的答案似乎是指定“ 1”,因为0.9版本会引起问题。
当我尝试将ѭ1file添加到我的gemfile并推送到Heroku时,出现此错误:
Unresolved dependencies detected; Installing...
You have modified your Gemfile in development but did not check
the resulting snapshot (Gemfile.lock) into version control
You have added to the Gemfile:
* rake (= 0.8.7)
FAILED: http://devcenter.heroku.com/articles/bundler
! Heroku push rejected,failed to install gems via Bundler
error: hooks/pre-receive exited with error code 1
To git@heroku.com:my_app.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to \'git@heroku.com:my_app.git\'
我的gemfile在Heroku上通常可以正常工作。我该怎么办?
解决方法
将此放在您的Rakefile中,上面需要\'rake \':
require \'rake/dsl_definition\'
, 每次更改Gemfile时,都需要ѭ5来更新锁文件(Gemfile.lock)。您遇到的错误并非特定于更改rake的版本。
bundle install
git commit -a -m \"update lockfile\"
git push heroku master
请注意您收到的错误消息:
您已经在开发中修改了Gemfile,但没有将生成的快照(Gemfile.lock)检查到版本控制中
, 经过大量的思考之后,我终于解决了这个问题。我所做的简短版本缺少很多实验,它是:
1)更改Gemfile以指定Rake 0.8.7
#in Gemfile
gem \"rake\",\"0.8.7\"
2)基于堆栈溢出问题Ruby on Rails和Rake问题,删除我之前添加到Rakefile中的hack:未初始化的常量Rake :: DSL:
因此,我的Rakefile现在又回到了我应用程序的标准Rakefile:
# Add your own tasks in files placed in lib/tasks ending in .rake,# for example lib/tasks/capistrano.rake,and they will automatically be available to Rake.
require File.expand_path(\'../config/application\',__FILE__)
require \'rake\'
MyApp::Application.load_tasks
3)更改Heroku以在Ruby 1.9.2中运行我的应用程序:
heroku stack:migrate bamboo-mri-1.9.2 --app myapp
git push heroku master
现在看来很好-计划的cron任务仍在运行。
编辑:确实运行良好,一次,然后下次我推东西时再次炸毁!啊我想我现在根据对话修复了问题,并添加了delayed_job
宝石。不知道如何建立任务作业:工作。
安装delayed_job
似乎不是一个很好的解决方案,但是它确实有效,我想我可能想在某个时候使用它,特别是在Heroku每小时一次的cron作业中(这不够频繁) -我可能想每五分钟运行一次。安装delayed_job
宝石后,我必须为其进行设置,否则Heroku会抱怨缺少delayed_jobs
桌子:
#add to gemfile
gem \'delayed_job\'
#at command line
bundle install
rails g delayed_job
rake db:migrate
git add -A
git commit -a -m \"added delayed_job gem\"
git push
heroku rake db:migrate --app myapp
heroku restart --app myapp
, 我有一个Rails 3.0.11应用程序,该应用程序在Gemfile中指定了rake版本0.8.7,以解决版本0.9.2 Rake :: DSL问题。
将应用程序转换为Rails 3.2.0(Heroku Cedar堆栈)后,我遇到了工作程序崩溃(耙任务)的问题。我将\“ gem \'rake \',\'0.8.7 \'\”更改为\“ gem \'rake \'\”,该版本捆绑了rake 0.9.2.2版本。工作人员停止使用新版本崩溃。
, 您的问题是由于未删除Gemfile.lock
文件引起的,而不是特定于Heroku的。删除Gemfile.lock
应该可以解决此问题,但会直接导致您遇到另一个问题:
To git@heroku.com:tailored-landing-pages.git
* [new branch] master -> master
manfred@painstation2:~/Desktop/projects/ror/ta/tlp307$ heroku rake db:migrate
rake aborted!
ninitialized constant Rake::DSL
/app/Rakefile:13:in `<class:Application>\'
/app/Rakefile:12:in `<module:Tlp307>\'
/app/Rakefile:11:in `<top (required)>\'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `load\'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2373:in `raw_load_rakefile\'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2007:in `block in load_rakefile\'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling\'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:2006:in `load_rakefile\'
/usr/ruby1.9.2/lib/ruby/1.9.1/rake.rb:1991:in `run\'
/usr/ruby1.9.2/bin/rake:31:in `<main>\'
不幸的是,我尚未找到解决该问题的解决方案,因为将Rake降级到0.8.7似乎在这里不起作用。如果其他人有答案,我将不胜感激。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。