Ask A Question

Notifications

You’re not receiving notifications from this thread.

Bundler's New Ruby Version File Option Discussion

Quick note, some of the documentation for some Ruby version managers (such as chruby which I use) instruct users to store the string literal "ruby-x.x.x" with the version in the .ruby-version. If you get an error like:

[!] There was an error parsing `Gemfile`: Illformed requirement ["ruby-3.x.x"]. Bundler cannot continue.

it means you probably have the string in there. Just update your .ruby-version to ONLY have the version and not the "ruby-" string prefix.

I use Heroku, so had to use the fallback File.read() approach, which really isn't that much of a fallback IMO, only requires a few more character.

I can't believe I never thought about this! So simple once you see it. Now I have a singular source of truth for my Ruby version :)

Chruby readme reference:
https://github.com/postmodern/chruby?tab=readme-ov-file#default-ruby

Reply

You could also use delete_prefix so you can leave the .ruby-version file as-is. 👍

ruby File.read(".ruby-version").delete_prefix("ruby-").strip
Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.