Gemfile
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.4'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 6.1.4'
# Use postgresql as the database for Active Record
gem 'pg', '~> 1.1'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# 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
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem 'rack-cors'
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
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'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem "active_model_serializers", "~> 0.10.12"
gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'master'
我的应用程序一直运行得很好,直到我开始开发一个需要ruby 2.6.3版本的新应用程序,我相信我意外地更改了ruby版本。
% rvm list rubies
ruby-2.6.3 [ missing bin/ruby ]
ruby-2.7.2 [ x86_64 ]
ruby-2.7.3 [ x86_64 ]
* ruby-2.7.4 [ x86_64 ]
# => - current
# =* - current && default
# * - default
我目前的ruby版本似乎是2.7.4,但应用程序表示我的版本是2.6.3
我收到的错误:
Your Ruby version is 2.6.3, but your Gemfile specified 2.7.4
我试过跟随
- 捆绑包
- gem更新捆绑包
- 删除ruby并通过自制程序重新安装
使用gemset来避免意外更改ruby版本,但现在使用命令:
rvm use 2.7.4 --default
https://rvm.io/gemsets/creating
在项目中,您需要创建一个yes gitignore文件
.ruby-gemset ->
cool_project #project_name
.ruby-version ->
2.7.4 #project ruby version
之后,你将有一个迷你的环境为每个项目,你不会意外破坏它。