Heroku Ruby Buildpack二次部署推送失败问题求助
大家好,我最近把Ruby版本从3.1.7升级到3.2.8之后遇到了一个棘手的问题:Heroku上的应用第一次部署能正常完成bundle install,但之后所有的二次部署都卡在了依赖检测环节。这个问题在2台不同的Heroku服务器上都能复现,我试过多种方式清除缓存、回滚服务器后重新部署、带着新代码清除缓存再部署,都没能解决。而且本地环境完全没问题,开发/测试环境和生产环境的区别只在于多了capybara、pry、rubocop这类测试开发工具。
下面是部署推送时遇到的错误日志:
remote: -----> Using Ruby version: ruby-3.2.8 remote: -----> Installing bundler 2.3.5 remote: -----> Installing dependencies using bundler 2.3.5 remote: Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4 remote: Bundle complete! 59 Gemfile dependencies, 138 gems now installed. remote: Gems in the groups 'development' and 'test' were not installed. remote: Bundled gems are installed into `./vendor/bundle` remote: Bundle completed (0.41s) remote: Cleaning up the bundler cache. remote: Running: bundle list remote: Could not find mini_portile2-2.8.8 in any of the sources remote: Install missing gems with `bundle install`. remote: remote: ! remote: ! Error detecting dependencies remote: ! remote: ! The Ruby buildpack requires information about your application’s dependencies to remote: ! complete the build. Without this information, the Ruby buildpack cannot continue. remote: ! remote: ! Command failed: `bundle list` remote: ! remote: ! Could not find mini_portile2-2.8.8 in any of the sources remote: ! Install missing gems with `bundle install`. remote: ! remote: ! Push rejected, failed to compile Ruby app. remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to [app name]
我的应用环境信息:
- Rails版本:6.1.7.10
- Node版本:16.13.2
- Heroku栈:Heroku-22
- Ruby版本:3.2.8
运行heroku releases:output -a [app name]时,还看到了这个错误:
bundler: failed to load command: rake (/app/vendor/bundle/ruby/3.2.0/bin/rake) /app/vendor/ruby-3.2.8/lib/ruby/3.2.0/bundler/definition.rb:910:in `block in verify_changed_sources!': Could not find gem 'capybara' in locally installed gems (Bundler::GemNotFound)
我现在有点摸不着头绪,想问问大家有没有下一步排查的建议?
补充说明:我把Gemfile也附在下面了,有个奇怪的点是刚才在生产环境运行heroku releases:output居然提到了开发环境的gem(capybara),我正在排查这个点。
当前使用的工具版本:
- Bundler v2.3.5(之前是v2.1.4,作为排查步骤的一部分升级了)
- ruby 3.2.8p263
在Heroku服务器上运行bundle platform得到的输出:
[DEPRECATED] Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. Make sure you run `bundle install` in non frozen mode and commit the result to make your lockfile secure. Your app has gems that work on these platforms: * ruby Your Gemfile specifies a Ruby version requirement: * ruby 3.2.8 Your current platform satisfies the Ruby version requirement.
编辑后的Gemfile内容:
source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } # TODO TEMP: Psych4 gem incompatible with Rails 6.1. Remove line after Rails 7.0.4+ gem 'psych', '< 4.0' # TODO TEMP: keep concurrent-ruby to 1.3.4 until Rails 7.1 gem 'concurrent-ruby', '1.3.4' #dotenv recomends being the first gem included gem 'dotenv-rails', groups: [:development, :test] # application environment vars # RAILS DEFAULTS gem 'rails', '~> 6.1.7.10' # Provides rails framework gem 'pg', '~> 1.2' # Use postgres with Active Record gem 'puma', '>= 5.6.4' # Use Puma as the app server gem 'sass-rails', '>= 6' # Use SCSS for stylesheets gem 'webpacker', '~> 4.0' gem 'jquery-rails', '>=4.3.4' # Use jquery as the Javascript library gem 'turbo-rails' # Hotwire's SPA-like page accelerator, to replace the old turbolink gem 'redis', '~> 4.5' # In memory datastore, required by actioncable # and sidekiq # Use Active Storage variant gem "spring", group: :development # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.7.5', require: false # bootsnap requires this, but from ruby 2.7, this is no longer bundled with ruby gem 'scanf' # as of ruby 3.0, rexml is no longer a default gem for ruby, and since it's used by simplecov and webdriver gem 'rexml' # CUSTOM GEMS (omitted, very few in numbers) # OUR FAVORITE GEMS gem 'devise' # User authentication gem 'devise-security' # Additional security options gem 'pundit' # Controller action permissions gem 'will_paginate' # Simple pagination helpers gem "sidekiq", '<7' # Enables ActiveJob gem 'sinatra', require: false # dependency of sidekiqs web console gem 'paperclip' # file attachments to models gem 'aws-sdk-s3' # s3 file storage gem 'aws-sdk-states' # aws step functions gem 'scout_apm' # performance monitor gem 'pgsync' # sync data across postgres dbs # FRONTEND gem 'font_awesome5_rails' # Loads of icons gem 'd3-rails' # d3 for info visualization gem 'rubyXL' # parse a template and modify .xlsx file gem 'gradient' # color gradient in ruby gem "view_component", '~> 3.0.0' # using ViewComponent for reusable frontend elements # APP SPECIFIC gem 'oj' # Better json parser gem 'sidekiq-scheduler', '<5' # schedule cron-like jobs with sidekiq gem 'fugit' # cron expression parser group :production do # For mail on heroku gem 'postmark-rails', '>= 0.10.0' end group :development, :test do gem 'pry-byebug' # Debugging console gem 'simplecov' # Code coverage for tests gem 'simplecov-cobertura', require: false # Code coverage report gem 'capybara', '~> 3.35' # integration testing tool gem 'selenium-webdriver', '~> 4.11' # manages test browser gem 'database_cleaner' # Used by Datum::Transactions module gem 'minitest-retry' # For retrying flaky system tests end group :development do gem 'listen', '~> 3.5.1' # Dependency of spring gem 'memory_profiler' # For memory profiling gem 'rack-mini-profiler' # in app profiler gem 'rubocop', '~>1.37.1', require: false gem 'rubocop-minitest', '~> 0.13.0' gem 'rubocop-rails' gem 'rubocop-performance' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] # security checks gem 'brakeman' # Reek code smelling gem 'reek' # sentry for exception reporting gem "sentry-ruby" ## integrations for sentry gem "sentry-rails" gem "sentry-sidekiq" # Contributed System credential for paid GEMs source "https://gems.contribsys.com/" do gem 'sidekiq-pro' # advanced sidekiq package end ruby "3.2.8"
备注:内容来源于stack exchange,提问作者G987

