简体   繁体   English

Bundler冲突-Heroku需要Bundler 2,但应用程序需要Bundler v <2

[英]Bundler conflict - Heroku requires Bundler 2 but app requires Bundler v< 2

Bundler is causing a build fail for my Heroku app. Bundler导致我的Heroku应用构建失败。 It is a ruby on rails app and was working perfectly and deployed on Heroku. 它是Rails应用程序上的一个红宝石,可以完美运行并部署在Heroku上。 I started getting the following build error only after I installed the datadog agent. 仅在安装了datadog代理后,我才开始出现以下构建错误。 The build error seemed easy enough to fix, but it has grown difficult. 生成错误似乎很容易修复,但变得越来越困难。


After removing my Gemfile.lock and reinstalling to make sure bundler version was > 2.0, I then started getting another build error. 删除我的Gemfile.lock并重新安装以确保捆绑程序版本> 2.0之后,然后开始出现另一个构建错误。 This time it was that the bundler version my project requires is < 2: 这次是我的项目需要的捆绑器版本为<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.

I updated the latest version on my system, like it suggests. 我按照系统提示更新了系统上的最新版本。 But then I run back into the first error that Bundler V2 is required for the Heroku build step. 但是随后我遇到了第一个错误,即Heroku构建步骤需要Bundler V2。

This is my Gemfile.lock: 这是我的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

Here is my Gemfile if that helps 这是我的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


I'm really at a loss an appreciate your help. 感谢您的帮助,我真的很茫然。 ANY SUGGESTIONS APPRECIATED! 任何建议!

The errors you are getting are coming from the remote computer, that is, the Heroku dyno. 您遇到的错误来自远程计算机,即Heroku dyno。 You can't follow the instructions in the warning (to update bundler) as you can't run arbitrary instructions on their servers. 您无法按照警告中的说明进行操作(以更新捆绑程序),因为您无法在其服务器上运行任意说明。 Heroku only support limited " carefully curated " versions of bundler. Heroku仅支持捆绑器的有限“ 精心策划 ”版本。

Normally when the bundler versions don't match it just gives a warning, not an error, so you can potentially just ignore it. 通常,当捆绑版本不匹配,它只是给出了一个警告,而不是错误,所以你有可能只是忽略它。 Personally I like to eliminate warnings (or supress them if elimination isn't possible) so that when new warnings pop up I am more likely to notice them and deal with them. 就我个人而言,我喜欢消除警告(如果无法消除,则抑制它们),以便在出现新警告时,我更有可能注意到并进行处理。

That being said, I was not able to "downgrade" my Gemfile.lock from 2.0.1 to 1.15.2. 话虽这么说,我无法将我的Gemfile.lock从2.0.1降级到1.15.2。 I had to first delete Gemfile.lock and then recreate it (presumably there are potentially breaking changes across these major versions). 我必须先删除Gemfile.lock,然后重新创建它(大概在这些主要版本中可能存在重大更改)。 I suspect this is the second problem you encountered. 我怀疑这是您遇到的第二个问题。

The best way around these warnings/errors is to match your local version of Bundler to Heroku's carefully curated version. 解决这些警告/错误的最佳方法是将本地版本的Bundler与精心策划的Heroku匹配。 That page above links to another page with the currently supported versions: 上面的页面链接到具有当前受支持版本的另一页面:
https://devcenter.heroku.com/articles/ruby-support#libraries https://devcenter.heroku.com/articles/ruby-support#libraries

As of today that's version 2.0.1 for Gemfile.locks bundled with 2.x and 1.15.2 for everything else. 截至今天,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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM