我正在尝试 运行 捆绑安装,此错误消息是什么意思?

I'm trying to run Bundle Install, what does this error message mean?

感谢您抽出宝贵时间阅读本文。我对此非常陌生,目前正在按照教科书进行学习 Rails,如果我学得慢,请见谅。我目前正在阅读 Rails 教程(第 3 版)中 Ruby 的第 5 章,这部分是我的错,因为我摆弄了 something(我我不太确定是什么)现在我收到这个错误:我正在尝试安装 Bootstrap,我应该在我的 gemfile 中添加一行代码。但是现在每次我尝试 运行 捆绑安装 时,我都会收到此错误。

[!] There was an error parsing `Gemfile`: You cannot specify the same gem twice with different version requirements.
You specified: rails (= 4.2.2) and rails (~> 6.0.3, >= 6.0.3.1). Bundler cannot continue.

 #  from /home/ubuntu/environment/sample_app/Gemfile:10
 #  -------------------------------------------
 #  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
 >  gem 'rails', '~> 6.0.3', '>= 6.0.3.1'
 #  # Use sqlite3 as the database for Active Record
 #  -------------------------------------------

我知道这可能是一些基本且显而易见的事情,但我会很感激明确的指导,因为我完全迷路了。任何帮助表示赞赏!这就是我的 Gemfile 的样子:

source 'https://rubygems.org'

gem 'rails',                '4.2.2'
gem 'bootstrap-sass',       '3.2.0.0'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.3'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.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', '> = 4.1.2', 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', '>= 3.3.0'
  gem 'listen', '~> 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'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  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]


如错误消息所述,您有几个 rails gem.

的声明

删除 gem 'rails', '4.2.2'(在文件顶部,在 source 'https://rubygems.org' 之后)和 运行 bundle install(或只是 bundle)。

希望对您有所帮助!

Rails 在您的 Gemfile 中定义了两次。

第一个在 第 3 行,第二个在 第 10 行。只需从第 3 行删除第一个,然后重试 bundle install