即使在 gemfile 中删除了 gem,heroku 中的机架迷你分析器也会出错

当我推送到 heroku master 时出现此错误:

remote: -----> Installing node-v12.16.2-linux-x64
remote: -----> Installing yarn-v1.22.4
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        NameError: uninitialized constant Rack::MiniProfiler
remote:        Did you mean?  MiniMime
remote:        /tmp/build_416cf9b1/config/initializers/rack_mini_profiler.rb:1:in `<main>'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/engine.rb:681:in `block in load_config_initializer'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4/lib/active_support/notifications.rb:205:in `instrument'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/engine.rb:680:in `load_config_initializer'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/engine.rb:634:in `block (2 levels) in <class:Engine>'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/engine.rb:633:in `each'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/engine.rb:633:in `block in <class:Engine>'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/initializable.rb:32:in `instance_exec'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/initializable.rb:32:in `run'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/initializable.rb:61:in `block in run_initializers'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/initializable.rb:50:in `each'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/initializable.rb:50:in `tsort_each_child'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/initializable.rb:60:in `run_initializers'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/application.rb:391:in `initialize!'
remote:        /tmp/build_416cf9b1/config/environment.rb:5:in `<main>'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/application.rb:367:in `require_environment!'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4/lib/rails/application.rb:533:in `block in run_tasks_blocks'
remote:        /tmp/build_416cf9b1/vendor/bundle/ruby/3.0.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define'
remote:        Tasks: TOP => environment
remote:        (See full trace by running task with --trace)
remote:
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected,failed to compile Ruby app.
remote:
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 7a96920071719fb5e5e9f1de7ca2a992afdd3266
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 7a96920071719fb5e5e9f1de7ca2a992afdd3266
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to spaces-todoapp-ror.
remote:
To https://git.heroku.com/spaces-todoapp-ror.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/spaces-todoapp-ror.git'

这是我当前的 Gemfile:

# frozen_string_literal: true

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

ruby '3.0.1'

# Bundle edge Rails instead: gem 'rails',github: 'rails/rails',branch: 'main'
gem 'rails','~> 6.1.4'
# Use postgresql as the database for active Record
gem 'pg','~> 1.1'
# Use Puma as the app server
gem 'puma','~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails','>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker','~> 5.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks','~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder','~> 2.7'
# Use Redis adapter to run action Cable in production
# gem 'redis','~> 4.0'
# Use active Model has_secure_password
# gem 'bcrypt','~> 3.1.7'

# Use active Storage variant
# gem 'image_processing','~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap','>= 1.4.4',require: false
gem 'devise'

group :development,:test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug',platforms: %i[mri mingw x64_mingw]
end

group :development do
  # access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console','>= 4.1.0'
  # Display performance information such as SQL time and flame graphs for each request in your browser.
  gem 'listen','~> 3.3'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara','>= 3.26'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

# Windows does not include zoneinfo files,so bundle the tzinfo-data gem
gem 'tzinfo-data',platforms: %i[mingw mswin x64_mingw jruby]

在开发的早期阶段,我安装了 rack-mini-profiler gem 以将新 Rails 应用程序中烦人的计时器移到底部。然后当我尝试推送到 heroku 时,我遇到了这个错误。然后我删除了 Gemfile 中的 gem,运行了 bundle install,还删除了 config/initializers 中的 rack mini profiler 文件。仍然得到同样的错误。我尝试删除 heroku 中的应用程序并启动一个新应用程序,当我推送时,我遇到了同样的错误。现在我什至删除了实际的 gem,但仍然是同样的错误。我什至扫描了 rails 文件并查找了关键字“rack”,但我什么也没找到。我不知道为什么当我现在在我的应用程序中找不到任何它的踪迹时,它仍然给我一个未初始化的常量。提前感谢您的帮助!

BOB464671240 回答:即使在 gemfile 中删除了 gem,heroku 中的机架迷你分析器也会出错

我修好了。 一开始我以为只是向 heroku remote 进行新的推送会“刷新”它并且忘记尝试找到机架迷你分析器,所以我做了一些微不足道的改变,比如删除一些评论——它没有用。然后我将这些更改推送到 github。将这些更改拉到本地,然后再次尝试推送到 heroku,仅此而已。不知道为什么它有效?‍♂️

本文链接:https://www.f2er.com/3508.html

大家都在问