-
-
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
Avoid error reporting relative path when validating frozen #5128
Avoid error reporting relative path when validating frozen #5128
Conversation
Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality. We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below. If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack. For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide |
Normally bundler uses end to end specs. I would grep specs for this specific error message and use the result as a base to reproduce this particular realworld situation (or a simplified version of it). The changes look good to me, by the way! |
When a path does not make a lot of sense.
To avoid potential crashes when trying to jump from a drive to another on Windows, and take the change refactor things a bit.
e365121
to
7c9a9a4
Compare
Actually one of our Windows specs just reproduced this error. See #6989. So I went ahead and edited this PR so that this similar error you were running into is also prevented. |
Thanks! |
…ive-path Avoid error reporting relative path when validating frozen (cherry picked from commit 4064fb6)
…ive-path Avoid error reporting relative path when validating frozen (cherry picked from commit 4064fb6)
…ive-path Avoid error reporting relative path when validating frozen (cherry picked from commit 4064fb6)
…ive-path Avoid error reporting relative path when validating frozen (cherry picked from commit 4064fb6)
In this commit, we update to 2.4.22, which is the final version of 2.4. Versions 2.4.20 and below fail the CI tests due to a bug (rubygems/rubygems#5128). This bug was fixed in 2.4.21. We will not switch to Bundler 2.5 as OCRAN supports Ruby 2.x.
When invoking
Bundler::Runtiume::setup
on a frozen bundle, and there is norelative path from PWD to our default lockfile, our attempt to pre-generate a
helpful message results in an
ArgumentError
.This is more likely to occur on Windows, for example if PWD is on the
C:
volume and our project is on the
D:
volume, our application entry-point isinvoked using an absolute path, and our application invokes
Bundler::setup
.What was the end-user or developer problem that led to this PR?
A customer invoking Logstash 7.15.x using an absolute path
D:\logstash-7.15.0\bin\logstash
from a shell whose PWD was on theC:\
volume resulted in anArgumentError
propagating up fromBundler::Definition#ensure_equivalent_gemfile_and_lockfile
. Logstash invokesBundler
directly in code with:frozen
attribute set totrue
.What is your fix for the problem, implemented in this PR?
Stdlib's
Pathname#relative_path_from
raises anArgumentError
if it cannot give a relative path.Since Bundler's usage doesn't actually require a relative path but is only meant to provide helpful guidance to the user should our invocation eventually fail, it makes sense to rescue the
ArgumentError
and simply use the absolute path when a relative path can't be built.I would appreciate guidance on how to write a test for this.
Bundler::Definition#ensure_equivalent_gemfile_and_lockfile
does not appear to be covered at all in unit tests, and in any case there are likely to be OS-specific instructions for what constitutes a different base (on my POSIX machine running jruby, I cannot getPathname#relative_path_from
to produce the sameArgumentError
).Make sure the following tasks are checked