I want to have a specific version of RubyGems for a project. I have tests that fail for 2.5.x but pass for 2.6.x, so I want to make sure users are using 2.6.x or higher. I know you can explicitly update the version of RubyGems, but can you somehow 'require' a specific version like you can for regular gems?
I don't believe it's possible to select from among multiple rubygems versions in a single Ruby installation. But you can ensure that the required version is being used. Put the following somewhere where it will be run early in your application's startup, such as the top of your Gemfile (which is just a Ruby file), or at the beginning of a script which doesn't use bundler:
required_rubygems_version = '2.6.0'
if Gem.rubygems_version < Gem::Version.create(required_rubygems_version)
raise "Please upgrade to rubygems #{required_rubygems_version}"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With