You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hopefully, I've got somewhere near to the cause of the issue in numtide/prj-spec#4 but opening issue here to help with tracking.
This occurs when using a "linked" git worktree (i.e. a worktree created with git worktree add).
Due to using git rev-parse --absolute-git-dir to discover the PRJ_ROOT in numtide/prj-spec#4 , PRJ_ROOT ends up being defined pointing to the git state directory for the linked worktree. For example see this abridged trace output;
tl;dr; I think the fix is in numtide/prj-spec#4 but additional context/investigation below in case it's helpful
Wwhat really threw me, was that it fails somewhat silently. What seems to happen instead is that the devshell version on the "main" git worktree (e.g. /mnt/user_persist/git/nix/nixos/ in this example) was used instead! (*As it turns out, this isn't consistent. Sometimes it'll just be the "wrong" commit). This was perplexing, since I was making modifications in the linked worktree, but they weren't having any effect.
I haven't been able to work out exactly what nix is doing when it encounters the .git/worktree/some-worktree URL. At first, I assumed it was just using the commit on the main worktree instead of the linked one, but it does appear to be aware, to an extent, that the worktree is different, only it finds the wrong (seemingly outdated) commit ref.
Although whether nix is behaving sensibly when interpreting a git+file://.../.git/worktrees/some-worktree or not, is probably irrelevant here since it would be inconsistent to use the work tree when running devshell in the "main" git work tree (equivalent to git rev-parse --show-toplevel which will be the same as "${GIT_DIR%/.git}" in this case), but then use a "git dir" (equivalent to git rev-parse --absolute-git-dir) for a linked git work tree.
Is this a nix bug?
I'm on the fence about whether to consider this a bug against nix itself too, since it does seem odd that using a `git+file://.../.git/worktrees/some-worktree` as the flake URL *almost* works in a way that is arguably worse than if it just failed explosively (assuming I've not made any mistake in my end) .
Then again, I don't think I've seen git itself or other tools visibly use the .git/worktrees/some-worktree path directly, so arguably it's a bit of an edge case.
In any case
before the source "$(fetchurl "https://raw.githubusercontent.com/paisano-nix/direnv/main/lib" "sha256-R3K8Flvbovj4IOvdlWNtQKLMMSQV464WjG9eU29ixHk=")" seems to work around the issue.
The text was updated successfully, but these errors were encountered:
Hopefully, I've got somewhere near to the cause of the issue in numtide/prj-spec#4 but opening issue here to help with tracking.
This occurs when using a "linked" git worktree (i.e. a worktree created with
git worktree add
).Due to using
git rev-parse --absolute-git-dir
to discover thePRJ_ROOT
in numtide/prj-spec#4 ,PRJ_ROOT
ends up being defined pointing to the git state directory for the linked worktree. For example see this abridged trace output;This leads to the later nix commands looking like this;
tl;dr; I think the fix is in numtide/prj-spec#4 but additional context/investigation below in case it's helpful
Wwhat really threw me, was that it fails somewhat silently. What seems to happen instead is that the devshell version on the "main" git worktree (e.g.
/mnt/user_persist/git/nix/nixos/
in this example) was used instead! (*As it turns out, this isn't consistent. Sometimes it'll just be the "wrong" commit). This was perplexing, since I was making modifications in the linked worktree, but they weren't having any effect.I haven't been able to work out exactly what nix is doing when it encounters the
.git/worktree/some-worktree
URL. At first, I assumed it was just using the commit on the main worktree instead of the linked one, but it does appear to be aware, to an extent, that the worktree is different, only it finds the wrong (seemingly outdated) commit ref.Although whether nix is behaving sensibly when interpreting a
git+file://.../.git/worktrees/some-worktree
or not, is probably irrelevant here since it would be inconsistent to use the work tree when running devshell in the "main" git work tree (equivalent togit rev-parse --show-toplevel
which will be the same as"${GIT_DIR%/.git}"
in this case), but then use a "git dir" (equivalent togit rev-parse --absolute-git-dir
) for a linked git work tree.Is this a nix bug?
I'm on the fence about whether to consider this a bug against nix itself too, since it does seem odd that using a `git+file://.../.git/worktrees/some-worktree` as the flake URL *almost* works in a way that is arguably worse than if it just failed explosively (assuming I've not made any mistake in my end) .Then again, I don't think I've seen git itself or other tools visibly use the
.git/worktrees/some-worktree
path directly, so arguably it's a bit of an edge case.In any case
edit: Forgot to mention a workaround
Adding;
before the
source "$(fetchurl "https://raw.githubusercontent.com/paisano-nix/direnv/main/lib" "sha256-R3K8Flvbovj4IOvdlWNtQKLMMSQV464WjG9eU29ixHk=")"
seems to work around the issue.The text was updated successfully, but these errors were encountered: