【发布时间】:2019-10-07 04:29:01
【问题描述】:
我遇到了一个问题,我看到其他人遇到过并尝试了许多提供的解决方案,但没有任何效果。当尝试将 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或类似的东西。这允许迁移,但后来我得到了错误并且测功机崩溃了。 - 尝试使用命令
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
希望有足够的信息。这简直是一场噩梦。
【问题讨论】:
-
你的
Gemfile.lock(BUNDLED WITH) 怎么样? -
我的
Gemfile.lock总是包含`bundler (>= 1.3.0)` 但在底部显示bundled with 2.0.1 -
你试过简单的
bundle exec heroku rails db:migrate吗? -
刚刚试过。仍然收到
You must use Bundler 2 or greater with this lockfile.
标签: ruby-on-rails ruby heroku rubygems bundler