遇到错误“尝试了多种解决方案后,您必须对此捆绑文件使用Bundler 2或更高版本。”

时间:2019-05-20 19:34:14

标签: ruby-on-rails ruby heroku rubygems bundler

我遇到了一个问题,我已经看到其他人遇到的问题,并尝试了许多提供的解决方案,但是没有任何效果。尝试将Rails应用程序部署到Heroku并达到必须heroku rake db:migrate的地步时,出现错误You must use Bundler 2 or greater with this lockfile.

我最初运行的是Ruby 2.6.0,但在阅读了一些已修复的帖子后升级到2.6.1。运行Rails 5.2.2。

我试图:

  • 删除锁定文件并捆绑安装
  • gem更新捆绑程序(至2.0)
  • 捆绑安装--system
  • heroku buildpacks:set
  • gem安装捆绑软件-
  • 尝试在Heroku上删除我的Rails应用并重置Heroku存储库并重新开始
  • 尝试了heroku rake:detach rake db:migrate之类的东西。这允许进行迁移,但是随后出现错误,并且dyno崩溃了。
  • 尝试使用命令web: bundle exec bin/rails server -p $PORT -e $RAILS_ENV worker: bundle exec sidekiq -C config/sidekiq.yml
  • 创建Procfile.dev

这里有一些代码也许可以阐明我的情况。

我的宝石文件:

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

ruby '2.6.1'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.2'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'
gem 'active_model_serializers'
gem 'httparty'
# 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 'jwt-auth', '~> 3.0'
# gem 'dotenv-rails', groups: [:development, :test]
gem "figaro"


gem "aws-sdk-s3", require: false

# 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
gem 'bootsnap', '>= 1.1.0', require: false

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


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]
end

group :development do
  gem 'listen', '>= 3.0.5', '< 3.2'


end


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

我尝试heroku open时的日志文件:

2019-05-20T19:18:37.154031+00:00 app[api]: Release v2 created by user demiansims@gmail.com
2019-05-20T19:18:37.154031+00:00 app[api]: Enable Logplex by user demiansims@gmail.com
2019-05-20T19:18:36.926353+00:00 app[api]: Release v1 created by user demiansims@gmail.com
2019-05-20T19:18:36.926353+00:00 app[api]: Initial release by user demiansims@gmail.com
2019-05-20T19:19:02.000000+00:00 app[api]: Build started by user demiansims@gmail.com
2019-05-20T19:19:52.512189+00:00 app[api]: Set LANG, RACK_ENV, RAILS_ENV, RAILS_LOG_TO_STDOUT, RAILS_SERVE_STATIC_FILES, SECRET_KEY_BASE config vars by user demiansims@gmail.com
2019-05-20T19:19:52.512189+00:00 app[api]: Release v3 created by user demiansims@gmail.com
2019-05-20T19:19:53.944345+00:00 app[api]: Deploy 3ab64d18 by user demiansims@gmail.com
2019-05-20T19:19:53.944345+00:00 app[api]: Release v6 created by user demiansims@gmail.com
2019-05-20T19:19:53.957391+00:00 app[api]: Scaled to console@0:Free rake@0:Free web@1:Free by user demiansims@gmail.com
2019-05-20T19:19:53.639739+00:00 app[api]: Attach DATABASE (@ref:postgresql-defined-55908) by user demiansims@gmail.com
2019-05-20T19:19:53.656114+00:00 app[api]: @ref:postgresql-defined-55908 completed provisioning, setting DATABASE_URL. by user demiansims@gmail.com
2019-05-20T19:19:53.639739+00:00 app[api]: Running release v4 commands by user demiansims@gmail.com
2019-05-20T19:19:53.656114+00:00 app[api]: Release v5 created by user demiansims@gmail.com
2019-05-20T19:19:57.332749+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 46673 -e production`
2019-05-20T19:19:56.000000+00:00 app[api]: Build succeeded
2019-05-20T19:19:59.100443+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-20T19:19:59.107493+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-20T19:19:59.038377+00:00 app[web.1]: /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)
2019-05-20T19:19:59.038393+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/lockfile_parser.rb:95:in `initialize'
2019-05-20T19:19:59.038394+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/definition.rb:83:in `new'
2019-05-20T19:19:59.038395+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/definition.rb:83:in `initialize'
2019-05-20T19:19:59.038397+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/dsl.rb:234:in `new'
2019-05-20T19:19:59.038398+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/dsl.rb:234:in `to_definition'
2019-05-20T19:19:59.038399+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/dsl.rb:13:in `evaluate'
2019-05-20T19:19:59.038402+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/definition.rb:34:in `build'
2019-05-20T19:19:59.038404+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler.rb:135:in `definition'
2019-05-20T19:19:59.038405+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler.rb:101:in `setup'
2019-05-20T19:19:59.038406+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/setup.rb:20:in `<top (required)>'
2019-05-20T19:19:59.038408+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
2019-05-20T19:19:59.038409+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
2019-05-20T19:19:59.038410+00:00 app[web.1]: from /app/config/boot.rb:3:in `<top (required)>'
2019-05-20T19:19:59.038411+00:00 app[web.1]: from bin/rails:3:in `require_relative'
2019-05-20T19:19:59.038413+00:00 app[web.1]: from bin/rails:3:in `<main>'
2019-05-20T19:19:59.079452+00:00 heroku[web.1]: Process exited with status 1
2019-05-20T19:20:02.333495+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 48713 -e production`
2019-05-20T19:20:05.071247+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-20T19:20:05.054251+00:00 heroku[web.1]: Process exited with status 1
2019-05-20T19:20:04.972527+00:00 app[web.1]: /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)
2019-05-20T19:20:04.972545+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/lockfile_parser.rb:95:in `initialize'
2019-05-20T19:20:04.972547+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/definition.rb:83:in `new'
2019-05-20T19:20:04.972548+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/definition.rb:83:in `initialize'
2019-05-20T19:20:04.972550+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/dsl.rb:234:in `new'
2019-05-20T19:20:04.972555+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/dsl.rb:234:in `to_definition'
2019-05-20T19:20:04.972557+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/dsl.rb:13:in `evaluate'
2019-05-20T19:20:04.972559+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/definition.rb:34:in `build'
2019-05-20T19:20:04.972560+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler.rb:135:in `definition'
2019-05-20T19:20:04.972562+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler.rb:101:in `setup'
2019-05-20T19:20:04.972563+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/bundler/setup.rb:20:in `<top (required)>'
2019-05-20T19:20:04.972565+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
2019-05-20T19:20:04.972566+00:00 app[web.1]: from /app/vendor/ruby-2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
2019-05-20T19:20:04.972568+00:00 app[web.1]: from /app/config/boot.rb:3:in `<top (required)>'
2019-05-20T19:20:04.972570+00:00 app[web.1]: from bin/rails:3:in `require_relative'
2019-05-20T19:20:04.972571+00:00 app[web.1]: from bin/rails:3:in `<main>'
2019-05-20T19:20:10.571751+00:00 app[api]: Starting process with command `bundle exec rake db:migrate` by user demiansims@gmail.com
2019-05-20T19:20:13.762466+00:00 heroku[run.5828]: State changed from starting to up
2019-05-20T19:20:13.765155+00:00 heroku[run.5828]: Awaiting client
2019-05-20T19:20:13.799505+00:00 heroku[run.5828]: Starting process with command `bundle exec rake db:migrate`
2019-05-20T19:20:18.499328+00:00 heroku[run.5828]: State changed from up to complete
2019-05-20T19:20:18.474268+00:00 heroku[run.5828]: Process exited with status 20
2019-05-20T19:22:57.021525+00:00 app[api]: Starting process with command `bundle exec rake db:migrate` by user demiansims@gmail.com
2019-05-20T19:23:00.672287+00:00 heroku[run.2331]: State changed from starting to up
2019-05-20T19:23:00.689268+00:00 heroku[run.2331]: Awaiting client
2019-05-20T19:23:00.740482+00:00 heroku[run.2331]: Starting process with command `bundle exec rake db:migrate`
2019-05-20T19:23:05.400934+00:00 heroku[run.2331]: State changed from up to complete
2019-05-20T19:23:05.385380+00:00 heroku[run.2331]: Process exited with status 20
2019-05-20T19:24:17.980956+00:00 app[api]: Starting process with command `bundle exec rake db:migrate` by user demiansims@gmail.com
2019-05-20T19:24:20.590557+00:00 heroku[run.2935]: Awaiting client
2019-05-20T19:24:20.812085+00:00 heroku[run.2935]: State changed from starting to up
2019-05-20T19:24:20.609194+00:00 heroku[run.2935]: Starting process with command `bundle exec rake db:migrate`
2019-05-20T19:24:25.018756+00:00 heroku[run.2935]: State changed from up to complete
2019-05-20T19:24:24.994002+00:00 heroku[run.2935]: Process exited with status 20
2019-05-20T19:32:18.494661+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=faunagram-api.herokuapp.com request_id=53b89a56-41ac-46b6-b8e7-328c912db131 fwd="184.152.71.64" dyno= connect= service= status=503 bytes= protocol=https
2019-05-20T19:32:19.118662+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=faunagram-api.herokuapp.com request_id=ca60c3fa-0092-48d1-807d-30f1f77b9745 fwd="184.152.71.64" dyno= connect= service= status=503 bytes= protocol=https

希望这些信息足够。这真是一场噩梦。

2 个答案:

答案 0 :(得分:0)

这是一个建议(不是解决方案),但我不必因果报应,请原谅我。尝试三件事:

bundle install && bundle update

bundle exec [COMMAND],即bundle exec heroku rake db:migrate

另外,通过您的gemfile并运行 gem pristine [GEMNAME]

我去过那里。祝您好运,如果您解决了,请及时更新!

答案 1 :(得分:0)

您安装的捆绑软件版本为2或更高且Gemfile.lock为BUNDLED WITH 2或更高的问题,

我已经遇到了很多次,将您的捆绑器降级到1.17.1将为您解决问题:-

  1. 通过运行gem list | grep "bundle"
  2. 获取所有捆绑程序版本
  3. 通过键入gem uninstall bundler -v <version_here>
  4. 开始删除它们
  5. 现在您尚未安装捆绑包gem,请通过运行gem install bundler -v 1.17.1
  6. 安装所需的gems
  7. 从您的项目中删除Gemfile.lock文件
  8. 导航到您的项目目录并运行bundle install
  9. 检查您的Gemfile.lock是否为BUNDLED WITH 1.17.1,通常您在文件末尾找到了这一行
  10. 您准备好了,部署您的应用程序,它将运行

希望这对您有用。