Skip to content
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

Prioritize path.system over path when it makes sense #3933

Merged
merged 11 commits into from Sep 14, 2020

Conversation

deivid-rodriguez
Copy link
Member

What was the end-user or developer problem that led to this PR?

If a user configures path.system true locally, and path foo globally, gems are still installed to foo, even if they should be installed to GEM_PATH, give that local configuration should have more priority.

What is your fix for the problem, implemented in this PR?

My fix is to remove some special logic that was preventing this case to work, and also to relax the path and path.system validation that makes sure there are no conflicts between them to allow this case.

Fixes #3931.

Tasks:

  • Describe the problem / feature
  • Write tests
  • Write code to solve the problem
  • Get code review from coworkers / friends

I will abide by the code of conduct.

To not mention deprecated `--path` flag.
This message is an informational piece, not a warning.
Since the behaviour is not specific to bundler 3.
@deivid-rodriguez deivid-rodriguez marked this pull request as draft September 8, 2020 09:21
Always fetch the value, since we'll be using it right after.
Keys should be defined in "ENV variable format", since that's what other
helpers expect, and makes it consistent with how the other
configurations are accessed.

This fixes the issue of the `Bundler.settings.locations` hash never
returning a `:default` key. It doesn't seem to cause any issues in
practice, but still.
Makes code more consistent, and allows further refactoring.
Since all settings are hashes now.
By extracting a `configs` helper which holds the different configuration
levels in the right order.
If `path.system` is configured locally, and `path` is configured
globally, gems should be installed to `path.system`.
@deivid-rodriguez deivid-rodriguez marked this pull request as ready for review September 8, 2020 15:33
@colby-swandale
Copy link
Member

colby-swandale commented Sep 9, 2020

Is this also a refactor? It's hard to spot what exactly the "fix" for the linked issue is.

@deivid-rodriguez
Copy link
Member Author

deivid-rodriguez commented Sep 9, 2020

Yes, I had to introduce quite a bit of refactoring to figure this out. The fix is the last commit: 418998c (the one including a regression spec, the rest of commits should keep specs green, but they don't fix anything).

The fix is essentially, instead of resolving path.system and path independently, we should resolve them at the same time. By "resolving" I mean going through each level of configuration (local, env, global) and choosing the first "non empty" one.

@deivid-rodriguez
Copy link
Member Author

@colby-swandale Do you plan on reviewing this? I was thinking of going ahead and merging if not.

I could split the refactoring to a separate changeset but since the refactoring is aimed at making the fix easier, and backporting the fix will require backporting the refactoring, I figured it was best to keep them together. I think a "commit by commit" review should work.

@colby-swandale
Copy link
Member

Sorry but I don't have the mental bandwidth to review at the moment.

@deivid-rodriguez
Copy link
Member Author

No problem. I'll merge for now, and we can iterate if any problems are found.

@deivid-rodriguez deivid-rodriguez merged commit 257005f into master Sep 14, 2020
@deivid-rodriguez deivid-rodriguez deleted the path_and_path_system_priority branch September 14, 2020 13:17
deivid-rodriguez added a commit that referenced this pull request Oct 5, 2020
Prioritize `path.system` over `path` when it makes sense

(cherry picked from commit 257005f)
deivid-rodriguez added a commit that referenced this pull request Oct 5, 2020
Prioritize `path.system` over `path` when it makes sense

(cherry picked from commit 257005f)
deivid-rodriguez added a commit that referenced this pull request Oct 5, 2020
Prioritize `path.system` over `path` when it makes sense

(cherry picked from commit 257005f)
deivid-rodriguez added a commit that referenced this pull request Oct 6, 2020
Prioritize `path.system` over `path` when it makes sense

(cherry picked from commit 257005f)
deivid-rodriguez added a commit that referenced this pull request Oct 6, 2020
Prioritize `path.system` over `path` when it makes sense

(cherry picked from commit 257005f)
deivid-rodriguez added a commit that referenced this pull request Oct 6, 2020
Prioritize `path.system` over `path` when it makes sense

(cherry picked from commit 257005f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How can I override path to the default path (Gem.dir)?
3 participants