【问题标题】:Heroku push error: "Could not detect rake tasks" ( Rails 6.1 )Heroku 推送错误:“无法检测到 rake 任务”(Rails 6.1)
【发布时间】:2021-04-14 18:36:39
【问题描述】:

我有一个“Rails 6.1.1”应用程序。每当我尝试部署它时,我都会收到此错误 -

remote: -----> Detecting rake tasks
remote: 
remote:  !
remote:  !     Could not detect rake tasks
remote:  !     ensure you can run `$ bundle exec rake -P` against your app
remote:  !     and using the production group of your Gemfile.
remote:  !     /tmp/build_05dae8c4/config/boot.rb:4:in `require': cannot load such file -- bootsnap/setup (LoadError)
remote:  !     from /tmp/build_05dae8c4/config/boot.rb:4:in `<top (required)>'
remote:  !     from /tmp/build_05dae8c4/bin/rake:3:in `require_relative'
remote:  !     from /tmp/build_05dae8c4/bin/rake:3:in `<main>'
remote:

我正在尝试使用 -

git push heroku master 

这是我的 Gemfile -

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.2'

gem 'rails', '~> 6.1.1'
gem 'puma', '~> 5.0'
gem 'sass-rails', '>= 6'
gem 'webpacker', '~> 5.0'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.7'
gem 'bcrypt', '~> 3.1.7'

gem 'bootsnap', '>= 1.4.4', require: false

group :development, :test do
  gem 'sqlite3', '~> 1.4'
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  gem 'web-console', '>= 4.1.0'
  gem 'rack-mini-profiler', '~> 2.0'
  gem 'listen', '~> 3.3'
  gem 'spring'
end

group :test do
  gem 'capybara', '>= 3.26'
  gem 'selenium-webdriver'
  gem 'webdrivers'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

我刚刚开始构建应用程序,并尝试使用基本控制器来部署它。我检查了所有内容,它仍然给了我这个信息。它在 localhost 中运行良好。

【问题讨论】:

    标签: ruby-on-rails heroku rubygems ruby-on-rails-6.1


    【解决方案1】:
    rake assets:precompile --dry-run
    

    然后如果你看到错误解决它 然后运行

    rake assets:precompile

    【讨论】:

    • * 没用。错误仍然出现 * 是的,有一个错误,它还建议我运行bundle update。在运行了bundle install 之后,我再次运行rake assets:precompile --dry-run。然后它显示了这个 - `**调用资产:预编译(first_time)**调用资产:环境(first_time)**执行(试运行)资产:环境**调用纱线:安装(first_time)**执行(试运行) ) yarn:install ** Execute (dry run) assets:precompile ` 虽然我在运行你建议的 2 个命令后将它推送到 heroku,但它仍然显示相同的错误。
    • 你用 --dry-run 试过了吗
    • 是的,我做到了,它建议我运行bundle update
    【解决方案2】:

    我在bundler version 2.2.4 上遇到了同样的错误。在我阅读下面链接的帖子并降级为bundler version 2.1.4 后,它为我解决了错误。

    https://stackoverflow.com/a/65333470/12483010

    【讨论】:

      【解决方案3】:

      在阅读thisthis 后,我修复了rake assets:precompile

      【讨论】:

        【解决方案4】:

        我尝试了rake assets:precompile 并按照 heroku 的建议指定了锁定的平台。

        这是我第一次部署到 heroku,在我第一次部署之前我没有将 RAILS_MASTER_KEY 设置为配置变量。一旦我设置好了,部署就成功了。

        【讨论】:

          猜你喜欢
          • 2016-07-23
          • 1970-01-01
          • 1970-01-01
          • 2018-07-09
          • 2021-05-06
          • 2020-09-21
          • 1970-01-01
          相关资源
          最近更新 更多