Home > Back-end >  How to set up a .ruby-version less strict?
How to set up a .ruby-version less strict?

Time:01-18

I like to setup the version of Ruby I am using on each project by setting up a .ruby-version file, but I find it very strict, especially if I am sharing my code.

If I declare this for example:

#.ruby-version
3.0.2

The code is going to request this ruby version and it won't accept any other no even: 3.0.4 which I know it will also work. This makes my code less sharable.

Is there any way I can use version description syntax like in the Gemfile file?

  • >= 3.0.0
  • >= 3.0.2, < 3.3
  • ~> 3.0

CodePudding user response:

It's funny that you even said "like in the Gemfile...", because you can define the required ruby version in the Gemfile, instead of having a .ruby-version file:

ruby '~> 3.0' # or whatever

gem 'some-dependency'
gem 'another-dependency'
# ...
  •  Tags:  
  • Related