-
-
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
fetchers/git: make relative path absolute for local repo #12107
Conversation
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.
I gave it a quick try and it does work for me:
ivan@tobati:~/nixops/aij$ /nix/store/bn0djaymav6qa4zg5vaskzcaija5nq2p-nix-2.26.0pre20241227_9111645/bin/nix flake update
warning: updating lock file '/home/ivan/nixops/aij/flake.lock':
• Updated input 'unstable':
'git+file:unstable?rev=3f0036916daca9836ba2c3f236b0ae051949a0a8' (2024-12-21)
→ 'git+file:unstable?ref=refs/heads/ipmiutil&rev=174ae1b581ddd6d5a6c55684da392e0baf500b1e' (2024-12-27)
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.
Partial fix
For the example in #9709, namely
doesn't this result in a lock file that has the absolute path of the original Git repo in it? I.e. if I run |
@edolstra Actually, no! It still gets locked to the relative path and shows up in |
cat > "$rootRepo"/flake.nix <<EOF | ||
{ | ||
inputs.subRepo.url = "git+file:./submodule"; | ||
outputs = { ... }: { }; | ||
} | ||
EOF | ||
git -C "$rootRepo" add flake.nix | ||
git -C "$rootRepo" commit -m "Add flake.nix" | ||
( | ||
cd "$rootRepo" | ||
# The submodule must be locked to the relative path, | ||
# _not_ the absolute path: | ||
[[ $(nix flake metadata --json | jq -r .locks.nodes.subRepo.locked.url) = "file:./submodule" ]] | ||
) |
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.
submodule
does get locked to the relative path file:./submodule
. I don't understand why but hey, it works!
Draft-ing and un-draft-ing to try to unlock the new CI... |
Rebased for GHA config update |
Relative, local git repo used to work (for submodules), but it fails after 3e0129c. This commit adds a test to prevent such failure in the future.
Rebased again, conflicts resolved, CI happy. |
Thanks! @mergify queue |
…on of NixOS/nix#9708 I got tired of manually running ``` /nix/store/bn0djaymav6qa4zg5vaskzcaija5nq2p-nix-2.26.0pre20241227_9111645/bin/nix flake update ``` for every update while waiting for the fix to make it upstreaam.
@mergify queue |
✅ The pull request has been merged automaticallyThe pull request has been merged automatically at 9c239d4 |
…2107 fetchers/git: make relative path absolute for local repo (backport #12107)
// | ||
// See: https://discourse.nixos.org/t/57783 and #9708 | ||
// | ||
repoInfo.url = repoInfo.isLocal ? std::filesystem::absolute(url.path).string() : url.to_string(); |
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.
I'm a bit baffled by this. As the comment notes, resolving relative to the cwd is wrong since it could be anything. So why are we doing this?
I fear that this PR enshrines some extremely undesirable semantics, namely that At the very least, we should print a warning that users should not rely on this behaviour. |
This was a calculated decision to merge. I believe an alternate result is not possible, and that the wrong behavior would only cause a direct failure ("mysteriously fail"). I've approved it as a workaround, not as a solution. I've written #12281 to clarify the situation and discuss / track the final solution. |
Yes, this is not the ideal behavior; it's a band-aid to fix the cryptic core-dumped assertion error as in #9708 (comment). Note that this PR was proposed and reviewed way before #12254. If the latter fix achieves the same purpose, Update: without 96bd9ba we would still land on an assertion error, so it would be better to proceed from #12277. |
Motivation
Closes #9708 (again).
This patch:
git+file:./${submodule}
to continue working.Context
Flake URIs such as
git+file:./${submodule}
used to work before 2.18, but broke in 2.19, was fixed later, and broke again recently since 3e0129c, resulting in a core-dumped assertion error in #9708 (comment).This PR suppresses the error and allows
git+file:./${submodule}
to continue working. However, this fix is not ideal and should potentially be superseded by a better submodule implementation in the future. See:git+file:./${submodule}
no longer works #9708A better fix is outlined by @roberth in https://discourse.nixos.org/t/57783, namely:
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.
Friendly pings: