【问题标题】:I'm trying to run Bundle Install, what does this error message mean?我正在尝试运行 Bundle Install,此错误消息是什么意思?
【发布时间】:2020-06-13 21:25:06
【问题描述】:

感谢您花时间阅读本文。我对此非常陌生,目前正在学习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


    【解决方案1】:

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

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

    希望这会有所帮助!

    【讨论】:

    • 因此,当我删除该行时,我收到以下错误消息:[!] There was an error parsing Gemfile: Illformed requirement ["> = 4.1.2"]. Bundler cannot continue. # from /home/ubuntu/environment/sample_app/Gemfile:32 # ------------------------------------------- # # Reduces boot times through caching; required in config/boot.rb > gem 'bootsnap', '> = 4.1.2', require: false # # -------------------------------------------
    • 当我删除第 10 行的其他定义时,我得到:[!] There was an error parsing Gemfile: Illformed requirement ["> = 4.1.2"]. Bundler cannot continue. # from /home/ubuntu/environment/sample_app/Gemfile:32 # ------------------------------------------- # # Reduces boot times through caching; required in config/boot.rb > gem 'bootsnap', '> = 4.1.2', require: false # # -------------------------------------------
    • @NR15 你能用当前版本的 Gemfile 编辑问题吗?
    • @NR15 Bootsnap 没有 4.1.2 版本。应该是gem 'bootsnap', '~> 1.4', '>= 1.4.6'
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-01
      • 2022-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多