-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add file
option to ruby
method in Gemfile
#6876
Add file
option to ruby
method in Gemfile
#6876
Conversation
Thanks! The original specification by indirect seems better to me though? I think it could get confusing if |
@deivid-rodriguez yeah, I can't think of one that doesn't cause even more confusion 😅 I've updated the logic to raise an error if you provide both. |
I know @hsbt brought up something similar, but I'll ask anyway. Could |
I personally think it's too much implicitness. Typing out |
One last thought: should we add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this should be documented in the gemfile.5
man page. Can we add a note about the new option?
@deivid-rodriguez done! |
457cfa3
to
fb9354b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Rebased and squashed, and going in!
Add `file` option to `ruby` method in Gemfile (cherry picked from commit 1c70a55)
Does this feature work with ruby 3.3.0.preview1? |
It is not part of Ruby 3.3.0.preview1 per my understanding, but it was released in Bundler 2.4.19 version. Just ensure you have right version. |
This issue is "rvm list" shows "3.0.0.preview1" (period before preview1) where .ruby-versions and bundler want "-" before preview1. Now have a "fix". |
What about support of asdf? Because they have slightly different syntax. |
This doesn't quite work right.
where my
Alternatively with
where my
|
The problem is
|
It seems we need better tests for this. Thank you for reporting. |
You could argue that it is not mocky enough. 👍 Perhaps a test that mocks the parse result for each distinct "standard" (not-a-real-standard) format of
Not sure if there is a comprehensive list anywhere of all the formats of |
I'm looking into fixing this now. FWIW this might be the original proposal for .ruby-version from 2012 and has received running updates along the way as things were decided. I'm of two minds for this behavior. One the one hand, Bundler could be opinionated about the format. We could simply say that if you put something into .ruby-version that is not a simple version, then Bundler won't read it. (In other words, a Steve Jobs "Don't hold it that way") On the other hand, this format is not up to bundler and has existed for a long time. It's used by rbenv, chruby, rvm and we have chosen to attempt to read asdf's format. It's trivial to trim ruby- off the front and |
For those who rely on the |
Thanks for taking up this discussion and for making sure we solve this as well as possible. For I am patching this to support removing Also for jruby/truffleruby folks out there, you might end up with something like this (this is not a recommendation, but just pointing out that the engine options are allowed with the file option) ruby file: ".ruby-version", engine: "jruby", engine_version: "9.4.3.0" $ cat .ruby-version
3.1.4 |
This is already documented on the [manpage](https://github.com/rubygems/rubygems/blob/6bbc8bed344eeaadcbd8dfcc6e20c9e1eb734d96/bundler/lib/bundler/man/gemfile.5.ronn?plain=1#L72-L80) but it seems like it makes sense to have on this page as well. Feature was implemented in rubygems/rubygems#6876 This copy is lifted from the manpage source https://github.com/rubygems/rubygems/blob/6bbc8bed344eeaadcbd8dfcc6e20c9e1eb734d96/bundler/lib/bundler/man/gemfile.5.ronn?plain=1#L72-L80
This is already documented on the [manpage](https://bundler.io/v2.5/man/gemfile.5.html#VERSION-required-) but it seems like it makes sense to have on this page as well. Feature was implemented in rubygems/rubygems#6876 This copy is lifted from the manpage source https://github.com/rubygems/rubygems/blob/6bbc8bed344eeaadcbd8dfcc6e20c9e1eb734d96/bundler/lib/bundler/man/gemfile.5.ronn?plain=1#L72-L80
This is already documented on the [manpage](https://bundler.io/v2.5/man/gemfile.5.html#VERSION-required-) but it seems like it makes sense to have on this page as well. Feature was implemented in rubygems/rubygems#6876 This copy is lifted from the manpage source https://github.com/rubygems/rubygems/blob/6bbc8bed344eeaadcbd8dfcc6e20c9e1eb734d96/bundler/lib/bundler/man/gemfile.5.ronn?plain=1#L72-L80 Co-authored-by: Albert Chae <albertchae@users.noreply.github.com>
Bundler [2.4.19](https://github.com/rubygems/rubygems/blob/master/bundler/CHANGELOG.md#2419-august-17-2023) [introduced](rubygems/rubygems#6876) the ability to read in the version of Ruby from the `.ruby-version` file. `ruby file: '.ruby-version'` Rails doesn't yet use this pattern, settling for explitely setting the Ruby version in both the `.ruby-version` file and the `Gemfile`. However, a lot of developers _will_ update the Gemfile to use the new `file:` syntax. When they do, the default Dockerfile will fail to build because when it attempts to bundle the gems, there is no `.ruby-version` file for it to refer to. This update copies over the `.ruby-version` file at the same time as the `Gemfile` and `Gemfile.lock` so bundler has everything it needs to bundle regardless of how the Ruby version is specified in the Gemfile.
…dler/CHANGELOG.md#2419-august-17-2023) [introduced](rubygems/rubygems#6876) the ability to read in the version of Ruby from the `.ruby-version` file. `ruby file: '.ruby-version'` Rails doesn't yet use this pattern, settling for explitely setting the Ruby version in both the `.ruby-version` file and the `Gemfile`. However, a lot of developers _will_ update the Gemfile to use the new `file:` syntax. When they do, the default Dockerfile will fail to build because when it attempts to bundle the gems, there is no `.ruby-version` file for it to refer to. This update copies over the `.ruby-version` file at the same time as the `Gemfile` and `Gemfile.lock` so bundler has everything it needs to bundle regardless of how the Ruby version is specified in the Gemfile.
…dler/CHANGELOG.md#2419-august-17-2023) [introduced](rubygems/rubygems#6876) the ability to read in the version of Ruby from the `.ruby-version` file. `ruby file: '.ruby-version'` Rails doesn't yet use this pattern, settling for explitely setting the Ruby version in both the `.ruby-version` file and the `Gemfile`. However, a lot of developers _will_ update the Gemfile to use the new `file:` syntax. When they do, the default Dockerfile will fail to build because when it attempts to bundle the gems, there is no `.ruby-version` file for it to refer to. This update copies over the `.ruby-version` file at the same time as the `Gemfile` and `Gemfile.lock` so bundler has everything it needs to bundle regardless of how the Ruby version is specified in the Gemfile.
Bundler [2.4.19](https://github.com/rubygems/rubygems/blob/master/bundler/CHANGELOG.md#2419-august-17-2023) [introduced](rubygems/rubygems#6876) the ability to read in the version of Ruby from the `.ruby-version` file. `ruby file: '.ruby-version'` Rails doesn't yet use this pattern, settling for explitely setting the Ruby version in both the `.ruby-version` file and the `Gemfile`. However, a lot of developers _will_ update the Gemfile to use the new `file:` syntax. When they do, the default Dockerfile will fail to build because when it attempts to bundle the gems, there is no `.ruby-version` file for it to refer to. This update copies over the `.ruby-version` file at the same time as the `Gemfile` and `Gemfile.lock` so bundler has everything it needs to bundle regardless of how the Ruby version is specified in the Gemfile.
Fixes #6742. Please read the original issue for full context.
You can now do this in your Gemfile: