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
... will never succeed with nix flake lock or nix flake update, instead printing a message along the lines of:
fatal: couldn't find remote ref refs/heads/some-tag
error: program 'git' failed with exit code 128
(use '--show-trace' to show detailed location information)
What's happening there is that it's assuming ref= refers to a branch (hence prefixing it with refs/heads/), but it refers to a tag.
Steps To Reproduce
Create a local git repository, with at least one commit, and a tag named some-tag pointing to that commit. The repository also needs to contain a flake.nix; the minimal one is { outputs = { self }: { }; }.
In a separate directory, create a flake.nix which references that repository as an input, using a URL in the form git+file:///path/to/repo?ref=some-tag.
Attempt to do nix flake lock to generate a flake.lock.
Expected behavior
The repository should be retrieved, the tag ref should be found, and the flake.lock should be created.
nix-env --version output
nix-env (Nix) 2.13.3
Additional context
This works fine if you use ref=refs/tags/some-tag instead. However, that may defy user expectations, since the git command-line tools accept both branch and tag names anywhere that they ask for a "ref".
I discovered this in a much more complicated situation, so I was greatly relieved that none of the nuances I dug into turned out to be relevant.
I've spent enough time on this that I want to try my hand at writing a patch, but it's not clear to me why nix thinks it needs to prefix the ref name in the first place, and I don't want to cause a regression by simply removing that logic. Does anybody have context on that?
Describe the bug
A flake.nix along the lines of:
... will never succeed with nix flake lock or nix flake update, instead printing a message along the lines of:
What's happening there is that it's assuming ref= refers to a branch (hence prefixing it with refs/heads/), but it refers to a tag.
Steps To Reproduce
Create a local git repository, with at least one commit, and a tag named
some-tag
pointing to that commit. The repository also needs to contain a flake.nix; the minimal one is{ outputs = { self }: { }; }
.In a separate directory, create a flake.nix which references that repository as an input, using a URL in the form
git+file:///path/to/repo?ref=some-tag
.Attempt to do
nix flake lock
to generate a flake.lock.Expected behavior
The repository should be retrieved, the tag ref should be found, and the flake.lock should be created.
nix-env --version
outputnix-env (Nix) 2.13.3
Additional context
This works fine if you use
ref=refs/tags/some-tag
instead. However, that may defy user expectations, since the git command-line tools accept both branch and tag names anywhere that they ask for a "ref".I discovered this in a much more complicated situation, so I was greatly relieved that none of the nuances I dug into turned out to be relevant.
This appears to be caused by
nix/src/libfetchers/git.cc
Line 565 in 635df5e
I've spent enough time on this that I want to try my hand at writing a patch, but it's not clear to me why nix thinks it needs to prefix the ref name in the first place, and I don't want to cause a regression by simply removing that logic. Does anybody have context on that?
Priorities
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: