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

问题描述 投票:0回答:2

感谢您抽出宝贵的时间阅读本文档。我对此非常陌生,目前正在学习一本用于学习Rails的教科书,因此,如果我迟迟无法接受指导,我们深表歉意。我目前正在Ruby on Rails教程(第3版)的第5章,这部分是我的错,因为我在弄弄something(我不确定是什么),现在却收到此错误:我正在尝试安装Bootstrap,并且应该在我的gemfile中添加一行代码。但是现在每次我尝试运行bundle install时,都会收到此错误。

[!] 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]


ruby-on-rails ruby gemfile
2个回答
0
投票

如错误消息所述,您有rails gem的几个声明。

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

希望这会有所帮助!


0
投票

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

第一个在第3行上,第二个在第10行上。只需从第3行中删除第一个,然后再次尝试bundle install

© www.soinside.com 2019 - 2024. All rights reserved.