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

时间:2019-02-17 01:12:15

标签: ruby-on-rails heroku bundler gemfile gemfile.lock

Bundler导致我的Heroku应用构建失败。它是Rails应用程序上的一个红宝石,可以完美运行并部署在Heroku上。仅在安装了datadog代理后,我才开始出现以下构建错误。构建错误似乎很容易修复,但变得越来越困难。


在删除我的Gemfile.lock并重新安装以确保捆绑器版本为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


非常感谢您的帮助。任何建议!

1 个答案:

答案 0 :(得分: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