部署到Heroku时出现Rails rake问题 [英] Rails rake issue when deploying to Heroku
问题描述
解决方案:我正在使用Bundler版本2.2.4运行ruby 2.6.6p146.按照@thiebo的建议,我降级为Bundler 2.1.2并成功了!步骤:
SOLUTION: I was running ruby 2.6.6p146 with Bundler version 2.2.4. As per @thiebo's suggestion, I downgraded to Bundler 2.1.2 and it worked! Steps:
- $ gem卸载捆绑程序
- [然后删除Gemfile.lock]
- $ gem install bundler --version'2.1.2'
I've tried these options, but nothing has worked: heroku push error: "Could not detect rake tasks"
我确实可以对我的应用运行bundle exec rake -P
I can indeed run bundle exec rake -P against my app
我尝试营救Rakefile,并将rspec放入我的Gemfile中:
I tried rescuing the Rakefile, and putting rspec into production in my Gemfile: Heroku could not detect rake tasks (LoadError: cannot load such file -- rspec/core/rake_task)
我在宝石文件中添加了"rake".
I added 'rake' to the gemfile.
尝试添加宝石机架超时": Heroku'无法检测到rake任务'
Tried adding gem 'rack-timeout': Heroku 'Could not detect rake tasks'
我也无济于事: https://github.com/rubygems/捆绑器/问题/3640
这是错误:
Bundle completed (36.93s)
Cleaning up the bundler cache.
Detecting rake tasks
!
! Could not detect rake tasks
! ensure you can run `$ bundle exec rake -P` against your app
! and using the production group of your Gemfile.
!
[...] rubygems_integration.rb:460:in `block in replace_bin_path': can't find executable rake for gem rake. rake is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception) from /[...]ruby/2.6.0/gems/bundler-2.0.2/lib/bundler/rubygems_integration.rb:491:in `block in replace_bin_path' from ./vendor/bundle/bin/rake:29:in `<main>'
![...]helpers/rake_runner.rb:106:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)
ensure you can run `$ bundle exec rake -P` against your app
and using the production group of your Gemfile.
/tmp/build_dcccbbf6_/vendor/bundle/ruby/2.6.0/gems/bundler-
2.0.2/lib/bundler/rubygems_integration.rb:460:in `block in replace_bin_path': can't find executable rake for gem rake. rake is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
from /tmp/build_dcccbbf6_/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.2/lib/bundler/rubygems_integration.rb:491:in `block in replace_bin_path'
from ./vendor/bundle/bin/rake:29:in `<main>'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/ruby.rb:1035:in `rake'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/rails4.rb:84:in `block (2 levels) in run_assets_precompile_rake_task'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/base.rb:190:in `log'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/rails4.rb:78:in `block in run_assets_precompile_rake_task'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/instrument.rb:17:in `block in instrument'
from /tmp/tmp.9BjaQ6WXw6/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/instrument.rb:16:in `instrument'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/base.rb:50:in `instrument'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/base.rb:46:in `instrument'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/rails4.rb:77:in `run_assets_precompile_rake_task'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/ruby.rb:111:in `block (2 levels) in compile'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/ruby.rb:1056:in `allow_git'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/ruby.rb:104:in `block in compile'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'
from /tmp/codon/tmp/buildpacks/63cff2a36c882a48324b4b7a5466efcada2e529a/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'
from [... a lot more lines like this]
! Push rejected, failed to compile Ruby app.
! Push failed
非常感谢,如果有人知道.
Big thanks, if anyone knows.
推荐答案
简短答案
使用Heroku支持的捆绑程序版本
gem uninstall bundler
gem install bundler --version '2.1.2'
rm Gemfile.lock
bundle install
git add Gemfile.lock
git commit -m "downgrade bundler to appease the Heroku gods"
git push heroku
此问题之前似乎已经发生: https://github.com/rubygems/bundler/issues/7486
This problem seems to have happened before: https://github.com/rubygems/bundler/issues/7486
这篇关于部署到Heroku时出现Rails rake问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!