rbenv: Set ruby version from Gemfile if .ruby-version file is missing
Not sure about all pros/cons for this but it seems configuring ruby version in two different files (Gemfile
for Heroku and bundler / .ruby-version
for rbenv) seems like one file too many.
I would expect rbenv to scan Gemfile for ruby version unless a .ruby-version file was present.
Makes sense?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 4
- Comments: 16 (7 by maintainers)
Commits related to this issue
- Initial commit — committed to selivanov-d/train_manager by selivanov-d 8 years ago
Just wanted to leave a note here for posterity: since a Gemfile is Ruby, you can always parse a ruby-version file to determine the version for the Gemfile:
I agree with @codyrobbins, maybe it is time to revisit this issue. My workplace is already in the process of migrating from
.ruby-version
toGemfile
.After reading @jeppester comment, I wanted to give an update regarding my situation with
rbenv
.The lack of support for this feature has been one of the major reasons why I changed recently to
rvm
and have been recommending it instead ofrbenv
.I really hope that you guys reconsider the decision in the near future.
I wish this decision would be revisited now that Bundler is the de facto dependency manager for Ruby. Shouldn’t simplicity for the end user trump simplicity of the internals of the tool? The fact that you have to specify the same Ruby version in two separate places just seems inelegant and unnecessary to me at this point—the
.ruby-version
file has become superfluous. I understand the argument for keeping this functionality in a plugin, but a plugin is a poor solution in a team environment. Rbenv has become such an indispensable part of so many people’s Ruby toolboxes that I think it warrants slightly tighter integration with other crucial pieces like Bundler 🙂For posterity, Bundler >=2.5.1 and Rubygems >=3.4.20 now support a file argument when specifying the ruby version in the Gemfile. For example:
can now become
@dbackeus Yep, not such a stretch anymore. However, I feel that this is still plugin material. Moreover, if we tweak rbenv to allow plugin hooks for this, then other people could come up with even cleverer version selection. Closing this in favor of @jasonkarns’s PR.
I believe that not having support for versions specified through Gemfiles will push users towards switching to rvm because it works “out of the box” and therefore is easier to use and recommend in a team environment.
Thanks for the issue link, I hadn’t seen it actually. Guess this is sort of a duplicate then. But maybe feels more relevant now that more or less everyone specifies their ruby version in the Gemfile?
Regarding a mention of not wanting to couple rbenv “even to bundler”… I guess bundler is now getting integrated in rubygems, which is already integrated in ruby. So maybe doesn’t seem like so much of a stretch anymore?