Fix bundler rubygems binstub not properly looking for bundler#2426
Fix bundler rubygems binstub not properly looking for bundler#24262 commits merged intoruby:masterfrom
Conversation
|
How is this fixing the issue? |
|
Because when you run the spec with this patch applied you get what you want, but when run without the patch you don't... 🤣. Seriously, I'm not sure. I'll comment over the code and throw some guesses. |
| @without_filtering = false | ||
|
|
||
| def self.without_filtering | ||
| without_filtering, @without_filtering = true, @without_filtering |
There was a problem hiding this comment.
So, I have no idea what this filtering intends to do, but I think the problem is that here the assignment is inverted (it should be without_filtering, @without_filtering = @without_filtering, true). That means that once the instance variable is set to true, it's never switched back. Since this variable is used further below in the bundler_version_with_reason method to prevent the method from returning an useful message, that's what it ends up happening.
So, I think this could also be fixed by inverting the assignment but I wonder what we're trying to achieve with all this untested code... 🤷♂️.
There was a problem hiding this comment.
🤦 yeah I think that sounds right
6db1bf2 to
6f32146
Compare
|
I managed to write a spec for this! 👍 |
|
Also, I think this fix might mean that |
6f32146 to
11b0171
Compare
|
I rebased this PR and also correct a typo, and a test description. |
11b0171 to
d2b3827
Compare
|
I think this is important for the bundler + rubygems integration. Any more thoughts / reviews? |
d2b3827 to
fa9c3b6
Compare
|
@bundlerbot r+ |
2426: Fix bundler rubygems binstub not properly looking for bundler r=hsbt a=deivid-rodriguez # Description: The problem is that when running a rubygems bundler binstub with a lock file locked to a non-installed bundler version, one would get the cryptic error message: ``` can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException) ``` where one tends to think... What? How is it not found if I just run it?! Partially closes rubygems/bundler#6595. Now the message is way more clear, but I guess it'd be better to actually run the command. Not sure if that's possible from a rubygems binstub, though. # Tasks: - [x] Describe the problem / feature - [x] Write tests - [x] ~Write~ Delete code to solve the problem - [ ] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md). Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
Build succeeded |
|
Thanks! 😃 |
* Enable Style/MethodDefParentheses in Rubocop
ruby/rubygems#2478
* Enable Style/MultilineIfThen in Rubocop
ruby/rubygems#2479
* Fix required_ruby_version with prereleases and improve error message
ruby/rubygems#2344
* Fix bundler rubygems binstub not properly looking for bundler
ruby/rubygems#2426
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Enable Style/MethodDefParentheses in Rubocop
ruby/rubygems#2478
* Enable Style/MultilineIfThen in Rubocop
ruby/rubygems#2479
* Fix required_ruby_version with prereleases and improve error message
ruby/rubygems#2344
* Fix bundler rubygems binstub not properly looking for bundler
ruby/rubygems#2426
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Enable Style/MethodDefParentheses in Rubocop
ruby/rubygems#2478
* Enable Style/MultilineIfThen in Rubocop
ruby/rubygems#2479
* Fix required_ruby_version with prereleases and improve error message
ruby/rubygems#2344
* Fix bundler rubygems binstub not properly looking for bundler
ruby/rubygems#2426
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
## Problem 1 Bundler 2.x cannot be used with a Gemfile.lock that specifies bundler 1.x: ``` BUNDLED WITH 1.16.4 ``` If you try, then Bundler 2.x will look for an installed bundler 1.x version and try to use it. If no such version exists on the system then an error is thrown: ``` can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException) ``` - ruby/rubygems#2426 - ruby/rubygems#2515 ## Problem 2 Likewise a version of bundler 1.x cannot be used on a project where a `BUNDLED WITH` specifies 2.x: ``` $ bundle -v 1.17.3 $ cat Gemfile.lock | grep -A 1 BUNDLED WITH BUNDLED WITH 2.0.1 $ bundle Traceback (most recent call last): 2: from /Users/rschneeman/.gem/ruby/2.6.0/bin/bundle:23:in `<main>' 1: from /Users/rschneeman/.rubies/ruby-2.6.0/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path' /Users/rschneeman/.rubies/ruby-2.6.0/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.0.0) required by your /private/tmp/default_ruby/Gemfile.lock. (Gem::GemNotFoundException) To update to the latest version installed on your system, run `bundle update --bundler`. To install the missing version, run `gem install bundler:2.0.0` ``` This is due to a bug in Rubygems 3.x ruby/rubygems#2592 ## Proposed Solution This PR implements a solution where we have a different "blessed" version of bundler for each major version. The way this is implemented is to read in a Gemfile.lock and to read in the `BUNDLED WITH` value. Then the major version is pulled out and converted into a "blessed" version. This allows for multiple major versions of bundler to be used on Heroku without sacrificing stability.
2426: Fix bundler rubygems binstub not properly looking for bundler r=hsbt a=deivid-rodriguez # Description: The problem is that when running a rubygems bundler binstub with a lock file locked to a non-installed bundler version, one would get the cryptic error message: ``` can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException) ``` where one tends to think... What? How is it not found if I just run it?! Partially closes rubygems/bundler#6595. Now the message is way more clear, but I guess it'd be better to actually run the command. Not sure if that's possible from a rubygems binstub, though. # Tasks: - [x] Describe the problem / feature - [x] Write tests - [x] ~Write~ Delete code to solve the problem - [ ] Get code review from coworkers / friends I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md). Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net> (cherry picked from commit 9b1c44a)
Description:
The problem is that when running a rubygems bundler binstub with a lock file locked to a non-installed bundler version, one would get the cryptic error message:
where one tends to think... What? How is it not found if I just run it?!
Partially closes rubygems/bundler#6595. Now the message is way more clear, but I guess it'd be better to actually run the command. Not sure if that's possible from a rubygems binstub, though.
Tasks:
WriteDelete code to solve the problemI will abide by the code of conduct.