Bundler冲突 - Heroku需要Bundler 2,但app需要Bundler v <2

问题描述 投票:1回答:1

Bundler导致我的Heroku应用程序的构建失败。它是rails上的ruby应用程序,可以完美地运行并部署在Heroku上。我在安装datadog代理后才开始出现以下构建错误。构建错误似乎很容易解决,但它变得越来越困难。


删除我的Gemfile.lock并重新安装以确保Bundler版本> 2.0后,我开始得到另一个构建错误。这次是我的项目所需的捆绑版本<2:

remote:        Bundler Output: Activating bundler (< 2) failed:
remote:        Could not find 'bundler' (1.17.3) required by your /tmp/build_3b256cc6024c5dcfd1bd0d030688678a/Gemfile.lock.
remote:        To update to the lastest version installed on your system, run `bundle update --bundler`.
remote:        To install the missing version, run `gem install bundler:1.17.3`
remote:        Checked in 'GEM_PATH=vendor/bundle/ruby/2.5.0', execute `gem env` for more information
remote:        
remote:        To install the version of bundler this project requires, run `gem install bundler -v '< 2'`
remote: 
remote:  !     Failed to install gems via Bundler.

我在系统上更新了最新版本,就像它建议的那样。但后来我回到第一个错误,即Heroku构建步骤需要Bundler V2。

这是我的Gemfile.lock:

  remote: https://rubygems.org/
  specs:
    actioncable (5.2.2)
      actionpack (= 5.2.2)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
    actionmailer (5.2.2)
      actionpack (= 5.2.2)
      actionview (= 5.2.2)
      activejob (= 5.2.2)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 2.0)
    actionpack (5.2.2)
      actionview (= 5.2.2)
      activesupport (= 5.2.2)
      rack (~> 2.0)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (5.2.2)
      activesupport (= 5.2.2)
      builder (~> 3.1)
      erubi (~> 1.4)
      rails-dom-testing (~> 2.0)
      rails-html-sanitizer (~> 1.0, >= 1.0.3)
    active_model_serializers (0.10.9)
      actionpack (>= 4.1, < 6)
      activemodel (>= 4.1, < 6)
      case_transform (>= 0.2)
      jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
    activejob (5.2.2)
      activesupport (= 5.2.2)
      globalid (>= 0.3.6)
    activemodel (5.2.2)
      activesupport (= 5.2.2)
    activerecord (5.2.2)
      activemodel (= 5.2.2)
      activesupport (= 5.2.2)
      arel (>= 9.0)
    activestorage (5.2.2)
      actionpack (= 5.2.2)
      activerecord (= 5.2.2)
      marcel (~> 0.3.1)
    activesupport (5.2.2)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 0.7, < 2)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    arel (9.0.0)
    aws-eventstream (1.0.1)
    aws-partitions (1.139.0)
    aws-sdk-core (3.46.1)
      aws-eventstream (~> 1.0)
      aws-partitions (~> 1.0)
      aws-sigv4 (~> 1.0)
      jmespath (~> 1.0)
    aws-sdk-kms (1.13.0)
      aws-sdk-core (~> 3, >= 3.39.0)
      aws-sigv4 (~> 1.0)
    aws-sdk-s3 (1.30.1)
      aws-sdk-core (~> 3, >= 3.39.0)
      aws-sdk-kms (~> 1)
      aws-sigv4 (~> 1.0)
    aws-sigv4 (1.0.3)
    builder (3.2.3)
    byebug (11.0.0)
    case_transform (0.2)
      activesupport
    concurrent-ruby (1.1.4)
    crass (1.0.4)
    erubi (1.8.0)
    ffi (1.0.11)
    globalid (0.4.2)
      activesupport (>= 4.2.0)
    i18n (1.5.3)
      concurrent-ruby (~> 1.0)
    jmespath (1.4.0)
    jsonapi-renderer (0.2.0)
    listen (3.1.5)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
      ruby_dep (~> 1.2)
    loofah (2.2.3)
      crass (~> 1.0.2)
      nokogiri (>= 1.5.9)
    mail (2.7.1)
      mini_mime (>= 0.1.1)
    marcel (0.3.3)
      mimemagic (~> 0.3.2)
    method_source (0.9.2)
    mimemagic (0.3.3)
    mini_mime (1.0.1)
    mini_portile2 (2.4.0)
    minitest (5.11.3)
    nio4r (2.3.1)
    nokogiri (1.10.1)
      mini_portile2 (~> 2.4.0)
    pg (1.1.4)
    puma (3.12.0)
    rack (2.0.6)
    rack-cors (1.0.2)
    rack-test (1.1.0)
      rack (>= 1.0, < 3)
    rails (5.2.2)
      actioncable (= 5.2.2)
      actionmailer (= 5.2.2)
      actionpack (= 5.2.2)
      actionview (= 5.2.2)
      activejob (= 5.2.2)
      activemodel (= 5.2.2)
      activerecord (= 5.2.2)
      activestorage (= 5.2.2)
      activesupport (= 5.2.2)
      bundler (>= 1.3.0)
      railties (= 5.2.2)
      sprockets-rails (>= 2.0.0)
    rails-dom-testing (2.0.3)
      activesupport (>= 4.2.0)
      nokogiri (>=a 1.6)
    rails-html-sanitizer (1.0.4)
      loofah (~> 2.2, >= 2.2.2)
    railties (5.2.2)
      actionpack (= 5.2.2)
      activesupport (= 5.2.2)
      method_source
      rake (>= 0.8.7)
      thor (>= 0.19.0, < 2.0)
    rake (12.3.2)
    rb-fsevent (0.10.3)
    rb-inotify (0.10.0)
      ffi (~> 1.0)
    ruby_dep (1.5.0)
    spring (2.0.2)
      activesupport (>= 4.2)
    spring-watcher-listen (2.0.1)
      listen (>= 2.7, < 4.0)
      spring (>= 1.2, < 3.0)
    sprockets (3.7.2)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.2.1)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    sqlite3 (1.3.13)
    thor (0.20.3)
    thread_safe (0.3.6)
    tzinfo (1.2.5)
      thread_safe (~> 0.1)
    websocket-driver (0.7.0)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.3)

PLATFORMS
  ruby

DEPENDENCIES
  active_model_serializers
  aws-sdk-s3
  byebug
  ffi (~> 1.0.9)
  listen (>= 3.0.5, < 3.2)
  nokogiri (~> 1.6, >= 1.6.7)
  pg
  puma (~> 3.11)
  rack-cors
  rails (~> 5.2.1)
  spring
  spring-watcher-listen (~> 2.0.0)
  sqlite3 (~> 1.3.6)
  tzinfo-data

RUBY VERSION
   ruby 2.5.1p57

BUNDLED WITH
   2.0.1

这是我的Gemfile,如果这有帮助

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

ruby '2.5.1'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.1'
# Use sqlite3 as the database for Active Record
gem 'pg'
gem 'ffi', '~> 1.0.9'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'active_model_serializers'

# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Reduces boot times through caching; required in config/boot.rb

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem 'rack-cors'

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

group :development do
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'nokogiri', '~> 1.6', '>= 1.6.7'
end


# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem "aws-sdk-s3", require: false


我真的不知所措,感谢你的帮助。任何建议都令人满意!

ruby-on-rails heroku bundler gemfile gemfile.lock
1个回答
0
投票

你得到的错误来自远程计算机,即Heroku dyno。您无法按照警告中的说明(更新捆绑包),因为您无法在其服务器上运行任意指令。 Heroku仅支持有限的“carefully curated”版本的捆绑器。

通常,当捆绑器版本不匹配时,它只会发出警告,而不是错误,因此您可能会忽略它。就个人而言,我喜欢消除警告(或者如果不能消除警告就压制它们),以便在弹出新警告时我更有可能注意到它们并处理它们。

话虽这么说,我无法将我的Gemfile.lock从2.0.1“降级”到1.15.2。我必须首先删除Gemfile.lock然后重新创建它(可能在这些主要版本中可能存在重大变化)。我怀疑这是你遇到的第二个问题。

围绕这些警告/错误的最佳方法是将本地版本的Bundler与Heroku精心策划的版本相匹配。上面的页面链接到具有当前支持的版本的另一个页面: https://devcenter.heroku.com/articles/ruby-support#libraries

截至今天,Gemfile.locks的2.0.1版与2.x和1.15.2捆绑在一起。

# To check which version(s) of bundler you have installed:
$ gem list | grep bundler
bundler (1.17.1)

# To install an older version
$ gem install bundler -v 1.15.2
Fetching: bundler-1.15.2.gem (100%)
...
1 gem installed

# To install supported version 2
$ gem install bundler -v 2.0.1
Fetching: bundler-2.0.1.gem (100%)
...
1 gem installed

# Check again:
$ gem list | grep bundler
bundler (2.0.1, 1.17.1, 1.15.2)

# Bundle with the latest installed version
$ bundle install

# Try to bundle with an older version (may break)
$ bundle _1.15.2_ install
Traceback...
Could not find 'bundler' (2.0.1) required by your Gemfile.lock (Gem::GemNotFoundException)

# Actually bundle with an older version
$ rm Gemfile.lock
$ bundle _1.15.2_ install
© www.soinside.com 2019 - 2024. All rights reserved.