问题描述
发生了什么:
- 最初我试图将这个简单的博客应用部署到 Heroku,但遇到了与我的
Gemfile.lock
的合并冲突问题,现在当然我也无法在我的终端上运行rails s
。立>
错误信息
- 我遇到的确切错误如下:
Traceback (most recent call last):
5: from bin/rails:2:in `<main>'
4: from bin/rails:2:in `load'
3: from /Users/leatinoso/codes/blog_app/bin/spring:7:in `<top (required)>'
2: from /Users/leatinoso/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.8/lib/bundler.rb:210:in `locked_gems'
1: from /Users/leatinoso/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.8/lib/bundler.rb:210:in `new'
/Users/leatinoso/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.8/lib/bundler/lockfile_parser.rb:70:in `initialize': Your Gemfile.lock contains merge conflicts. (Bundler::LockfileError)
Run `git checkout HEAD -- Gemfile.lock` first to get a clean lock.
到目前为止做了什么
-
按照此 Stackoverflow post 操作,我仍然遇到相同的错误。从本质上讲,它建议我运行
git checkout HEAD -- Gemfile.lock
和bundle install
。 -
我还审查了这个 Github post,它也提出了同样的建议。
我的 Rails 设置
Rails 6.1.4
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [arm64-darwin20]
Node -v: v14.15.4
Yarn -v: 1.22.10
Gemfile*
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.2'
# Bundle edge Rails instead: gem 'rails',github: 'rails/rails',branch: 'main'
gem 'rails','~> 6.1.4'
<<<<<<< HEAD
# Use postgres as the database for Active Record
=======
# Use postgresql as the database for Active Record
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
gem 'pg'
# Use Puma as the app server
gem 'puma','~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails','>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker','~> 5.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks','~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder','~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis','~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt','~> 3.1.7'
# Use Active Storage variant
# gem 'image_processing','~> 1.2'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap','>= 1.4.4',require: false
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
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console','>= 4.1.0'
# display performance information such as sql time and flame graphs for each request in your browser.
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
gem 'rack-mini-profiler','~> 2.0'
gem 'listen','~> 3.3'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
<<<<<<< HEAD
=======
# Solargraph is a Ruby gem that provides intellisense features
gem 'solargraph'
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara','>= 3.26'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
end
# Windows does not include zoneinfo files,so bundle the tzinfo-data gem
gem 'tzinfo-data',platforms: [:mingw,:mswin,:x64_mingw,:jruby]
Gemfile.lock
GEM
remote: https://rubygems.org/
specs:
actioncable (6.1.4)
actionpack (= 6.1.4)
activesupport (= 6.1.4)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailBox (6.1.4)
actionpack (= 6.1.4)
activejob (= 6.1.4)
activerecord (= 6.1.4)
activestorage (= 6.1.4)
activesupport (= 6.1.4)
mail (>= 2.7.1)
actionmailer (6.1.4)
actionpack (= 6.1.4)
actionview (= 6.1.4)
activejob (= 6.1.4)
activesupport (= 6.1.4)
mail (~> 2.5,>= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.4)
actionview (= 6.1.4)
activesupport (= 6.1.4)
rack (~> 2.0,>= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0,>= 1.2.0)
actiontext (6.1.4)
actionpack (= 6.1.4)
activerecord (= 6.1.4)
activestorage (= 6.1.4)
activesupport (= 6.1.4)
nokogiri (>= 1.8.5)
actionview (6.1.4)
activesupport (= 6.1.4)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1,>= 1.2.0)
activejob (6.1.4)
activesupport (= 6.1.4)
globalid (>= 0.3.6)
activemodel (6.1.4)
activesupport (= 6.1.4)
activerecord (6.1.4)
activemodel (= 6.1.4)
activesupport (= 6.1.4)
activestorage (6.1.4)
actionpack (= 6.1.4)
activejob (= 6.1.4)
activerecord (= 6.1.4)
activesupport (= 6.1.4)
marcel (~> 1.0.0)
mini_mime (>= 1.1.0)
activesupport (6.1.4)
concurrent-ruby (~> 1.0,>= 1.0.2)
i18n (>= 1.6,< 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.0)
public_suffix (>= 2.0.2,< 5.0)
<<<<<<< HEAD
=======
ast (2.4.2)
backport (1.2.0)
benchmark (0.1.0)
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
bindex (0.8.1)
bootsnap (1.7.5)
msgpack (~> 1.0)
builder (3.2.4)
byebug (11.1.3)
capybara (3.35.3)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (>= 1.5,< 3.0)
xpath (~> 3.2)
childprocess (3.0.0)
concurrent-ruby (1.1.9)
crass (1.0.6)
<<<<<<< HEAD
=======
diff-lcs (1.4.4)
e2mmap (0.1.0)
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
erubi (1.10.0)
ffi (1.15.3)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
<<<<<<< HEAD
jbuilder (2.11.2)
activesupport (>= 5.0.0)
=======
jaro_winkler (1.5.4)
jbuilder (2.11.2)
activesupport (>= 5.0.0)
kramdown (2.3.1)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
listen (3.5.1)
rb-fsevent (~> 0.10,>= 0.10.3)
rb-inotify (~> 0.9,>= 0.9.10)
loofah (2.10.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (1.0.1)
method_source (1.0.0)
mini_mime (1.1.0)
mini_portile2 (2.5.3)
minitest (5.14.4)
msgpack (1.4.2)
nio4r (2.5.7)
nokogiri (1.11.7)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
<<<<<<< HEAD
=======
parallel (1.20.1)
parser (3.0.0.0)
ast (~> 2.4.1)
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
pg (1.2.3)
public_suffix (4.0.6)
puma (5.3.2)
nio4r (~> 2.0)
racc (1.5.2)
rack (2.2.3)
rack-mini-profiler (2.3.2)
rack (>= 1.2.0)
rack-proxy (0.7.0)
rack
rack-test (1.1.0)
rack (>= 1.0,< 3)
rails (6.1.4)
actioncable (= 6.1.4)
actionmailBox (= 6.1.4)
actionmailer (= 6.1.4)
actionpack (= 6.1.4)
actiontext (= 6.1.4)
actionview (= 6.1.4)
activejob (= 6.1.4)
activemodel (= 6.1.4)
activerecord (= 6.1.4)
activestorage (= 6.1.4)
activesupport (= 6.1.4)
bundler (>= 1.15.0)
railties (= 6.1.4)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.1.4)
actionpack (= 6.1.4)
activesupport (= 6.1.4)
method_source
rake (>= 0.13)
thor (~> 1.0)
<<<<<<< HEAD
rake (13.0.6)
=======
rainbow (3.0.0)
rake (13.0.5)
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (2.1.1)
<<<<<<< HEAD
=======
reverse_markdown (2.0.0)
nokogiri
rexml (3.2.4)
rubocop (0.90.0)
parallel (~> 1.10)
parser (>= 2.7.1.1)
rainbow (>= 2.2.2,< 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.3.0,< 1.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0,< 2.0)
rubocop-ast (0.8.0)
parser (>= 2.7.1.5)
ruby-progressbar (1.11.0)
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
rubyzip (2.3.2)
sass-rails (6.0.0)
sassc-rails (~> 2.1,>= 2.1.1)
sassc (2.4.0)
ffi (~> 1.9)
sassc-rails (2.1.2)
railties (>= 4.0.0)
sassc (>= 2.0)
sprockets (> 3.0)
sprockets-rails
tilt
selenium-webdriver (3.142.7)
childprocess (>= 0.5,< 4.0)
rubyzip (>= 1.2.2)
semantic_range (3.0.0)
<<<<<<< HEAD
=======
solargraph (0.42.4)
backport (~> 1.2)
benchmark
bundler (>= 1.17.2)
diff-lcs (~> 1.4)
e2mmap
jaro_winkler (~> 1.5)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.1)
parser (~> 3.0)
reverse_markdown (>= 1.0.5,< 3)
rubocop (>= 0.52)
thor (~> 1.0)
tilt (~> 2.0)
yard (~> 0.9,>= 0.9.24)
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
spring (2.1.1)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1,< 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (1.1.0)
tilt (2.0.10)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
<<<<<<< HEAD
=======
unicode-display_width (1.7.0)
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
web-console (4.1.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webdrivers (4.6.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (>= 3.0,< 4.0)
webpacker (5.4.0)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
<<<<<<< HEAD
=======
yard (0.9.26)
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
zeitwerk (2.4.2)
PLATFORMS
ruby
DEPENDENCIES
bootsnap (>= 1.4.4)
byebug
capybara (>= 3.26)
jbuilder (~> 2.7)
listen (~> 3.3)
pg
puma (~> 5.0)
rack-mini-profiler (~> 2.0)
rails (~> 6.1.4)
sass-rails (>= 6)
selenium-webdriver
<<<<<<< HEAD
=======
solargraph
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
spring
turbolinks (~> 5)
tzinfo-data
web-console (>= 4.1.0)
webdrivers
webpacker (~> 5.0)
RUBY VERSION
ruby 2.7.2p137
BUNDLED WITH
2.2.8
解决方法
您的 Gemfile 和 Gemfile.lock 都存在合并冲突。您无法从具有合并冲突的 Gemfile 生成新的 Gemfile.lock。
首先,删除 Gemfile 中的合并冲突。
gem 'rails','~> 6.1.4'
<<<<<<< HEAD
# Use postgres as the database for Active Record
=======
# Use postgresql as the database for Active Record
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
可能变成:
gem 'rails','~> 6.1.4'
# Use postgresql as the database for Active Record
还有:
<<<<<<< HEAD
=======
# Solargraph is a Ruby gem that provides intellisense features
gem 'solargraph'
>>>>>>> 83d186c9a3ca227a4c1aea18936043ded82ceb2e
可能变成:
# Solargraph is a Ruby gem that provides intellisense features
gem 'solargraph'
在您认为合适的情况下保留或移除日光图。
然后,重新生成锁文件。我可能会从一个新的锁文件开始。
$ rm Gemfile.lock
$ bundle install
或者,从没有合并冲突的提交中检查锁定文件,然后运行 bundle install
来更新它。