-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Restore builtins.pathExists
behavior on broken symlinks
#9985
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Per #9585 (comment) actually 2.18 is wrong, and the newer behavior that makes more sense is also the original older behavior. |
builtins.pathExists
behavior on broken symlinks
Commit 83c067c changed `builtins.pathExists` to resolve symlinks before checking for existence. Consequently, if the path refers to a symlink itself, existence of the target of the symlink (instead of the symlink itself) was checked. Restore the previous behavior by skipping symlink resolution in the last component.
0eca5cf
to
89e21ab
Compare
The obviously correct behavior for the directory thing is now implemented again, along with a test to prevent re-regression. |
@alois31 hmm so I am wondering whether the trailing slash should make a difference, as I believe is how its implemented. One way to rationalize the trailing |
Yeah, that would be my reasoning as well. The comment "SourcePath doesn't know about trailing slash." applies here too. |
Ah I see. I guess I am contemplating that |
Interesting idea. Investigating this exposed another regression: |
@alois31 my understanding is that in fact for many years |
Check out #9881. You can use the callback and a |
Discussed during the Nix maintainers meeting on 2024-02-12.
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2024-02-12-nix-team-meeting-minutes-123/39775/1 |
Hm, |
@alois31 |
@Ericson2314 Why should it stay separate, because it represents some kind of "abstract" path (like the "path" type in the Nix language)? Then at least the things not belonging into that (for example the second copy of the symlink resolution code) should be merged into |
Yes, and yes. |
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.
The rest of the Nix team pointed out we want a bug fix that we can backport, so I am approving this as-is after all. Hopefully @alois31 you are still interested working on the other solution in a follow-up :).
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 2.19-maintenance
git worktree add -d .worktree/backport-9985-to-2.19-maintenance origin/2.19-maintenance
cd .worktree/backport-9985-to-2.19-maintenance
git switch --create backport-9985-to-2.19-maintenance
git cherry-pick -x 89e21ab4bd1561c6eab2eeb63088f4e34fa4059f e27b7e04bf38c1fdf342d6e15b2c003ca9b92cb1 |
Successfully created backport PR for |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2024-02-16-nix-team-meeting-minutes-124/39870/1 |
@Ericson2314 (regression started in 2.20, so 2.19 backport not necessary) |
Ah yes, I misread #9901. |
@@ -115,7 +115,7 @@ StringMap EvalState::realiseContext(const NixStringContext & context) | |||
return res; | |||
} | |||
|
|||
static SourcePath realisePath(EvalState & state, const PosIdx pos, Value & v, bool resolveSymlinks = true) | |||
static SourcePath realisePath(EvalState & state, const PosIdx pos, Value & v, std::optional<SymlinkResolution> resolveSymlinks = SymlinkResolution::Full) |
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.
BTW, instead of an std::optional
, wouldn't it be cleaner to have a SymlinkResolution::None
alternative?
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.
Let's see how much of that footgun remains at all after working on the nicer fix.
Because it broke colmena, zhaofengli/colmena#190 Ref: - NixOS/nix#9497 - NixOS/nix#9901 - NixOS/nix#9985
@alois31 are you still interested in working on the follow-up cleanup? |
I fear I will not be able to work on this, sorry. The task seems to be much bigger than initially anticipated and I'm not up to it. |
Restore `builtins.pathExists` behavior on broken symlinks (cherry picked from commit d53c890) === note that this variant differs markedly from the source commit because we haven't endured quite as much lazy trees. Change-Id: I0facf282f21fe0db4134be5c65a8368c1b3a06fc
Because it broke colmena, zhaofengli/colmena#190 Ref: - NixOS/nix#9497 - NixOS/nix#9901 - NixOS/nix#9985
Commit 83c067c changed
builtins.pathExists
to resolve symlinks before checking for existence. Consequently, if the path refers to a symlink itself, existence of the target of the symlink (instead of the symlink itself) was checked. Restore the previous behavior by skipping symlink resolution in the last component.Motivation
Restore backwards compatibility.
Context
Fixes: #9901
Priorities and Process
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.