【问题标题】:How to fix "Your Ruby version is 2.3.3, but your Gemfile specified 2.7.1" when i use bundle install当我使用捆绑安装时如何修复“您的 Ruby 版本是 2.3.3,但您的 Gemfile 指定了 2.7.1”
【发布时间】:2020-09-13 22:02:52
【问题描述】:

当我执行“捆绑安装”时,会发生这种情况:您的 Ruby 版本是 2.3.3,但您的 Gemfile 指定的是 2.7.1 我能做什么?我正在使用我的电脑、Git Bash 和 Visual Studio

Error here

我的宝石文件:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.1'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.3'
# 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', '>= 1.4.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'
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


【解决方案1】:

您需要在您的机器上安装 ruby​​ 2.7.1 版才能继续。

或者,您可以更改 Gemfile 中指定的“ruby-version”以匹配您所拥有的 (2.3.3)。这是一个相当大的变化,该项目可能无法使用这么旧的版本。

您使用的是 ruby​​ 版本管理器吗?这个Gemfile是哪里来的?

如果这是因为您使用rails new 启动了一个新的 Rails 项目,那么您可能希望使用比 2.3.3 更现代的 ruby​​ 版本运行,这意味着(正如我在第一行所说的) ,您需要升级系统的默认 ruby​​。

【讨论】:

  • 我在我的电脑上再次卸载并安装了 2.7.1 版,以至于我在问题中的打印显示它是我的 Ruby 的当前版本,但问题没有解决.我想我没有 RVM。是的,我使用rails new 创建文件。
  • 我会警告不要升级系统的 Ruby,事情将取决于它,系统更新可能会覆盖它。而是使用 RubyInstaller 安装一个全新的 Ruby。
【解决方案2】:

我以为你可以按照这个教程https://medium.com/ruby-on-rails-web-application-development/how-to-install-rubyonrails-on-windows-7-8-10-complete-tutorial-2017-fc95720ee059,当你得到 ruby​​ 2.7.1 时,你可以毫无问题地开始。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-29
    • 2021-11-18
    • 2013-10-20
    • 1970-01-01
    • 2016-03-04
    • 2014-05-27
    • 2018-06-09
    相关资源
    最近更新 更多