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

fetchGit can't handle annotated tags #3701

Open
jakubgs opened this issue Jun 16, 2020 · 14 comments · May be fixed by #6766
Open

fetchGit can't handle annotated tags #3701

jakubgs opened this issue Jun 16, 2020 · 14 comments · May be fixed by #6766
Labels

Comments

@jakubgs
Copy link

jakubgs commented Jun 16, 2020

Description

Currently builtins.fetchGit does not seem to handle annotated tags and fails with:

error: cannot update ref 'refs/heads/xyz': trying to write non-commit object 098abc123 to branch 'refs/heads/xyz'

Reproduction

You can see me reproduce this in status-im/status-mobile#10825.

Docs

This was reported once in #2385 and a fix for docs was applied in ae244af by adding:

Due to a bug #2385 only non-annotated tags can be fetched.

To documentation of builtins.fetchGit, but that change does not seem to be there in current docs:
https://nixos.org/nix/manual/#ssec-builtins
And there doesn't appear to be any fix in sight.

Solutions

If the fix is difficult to implement for builtins.fetchGit could we at least update the documentation with this information and make fetchGit return an error that actually makes sense instead of this trying to write non-commit object nonsense?

@jakubgs jakubgs added the bug label Jun 16, 2020
@justinlovinger
Copy link

It looks like you can fix this error by using ref = "refs/tags/my-tag" instead of ref = "my-tag". Is there a good reason Nix uses refs/heads/ instead of refs/tags/ for tags? Even if branches are not found under refs/tags/, Nix could try both refs/heads/ and refs/tags/. Or perhaps fetchGit should have separate branch = and tag = arguments, instead of a single ref =.

@jakubgs
Copy link
Author

jakubgs commented Aug 15, 2020

Separate arguments would be a pain considering how developers use this. For example in our repo we have a JSON file that specifies the version of a library for our application that is bundled into it at build time. Developers usually use branches or sometimes specific commits, while stable builds use tags. If there were separate arguments we'd need automation to detect which is which. Pretty sure we're not the only ones that do this.

@jakubgs
Copy link
Author

jakubgs commented Aug 15, 2020

Using separate arguments could also be a royal pain for something like yarn2nix which we use.

@FRidh
Copy link
Member

FRidh commented Aug 15, 2020

Earlier issue #2385 which this one duplicates but which was closed with ae244af. The issue has indeed not really been fixed. Maybe @Ma27 knows more about this issue, having worked on fetchTree?

@Ma27
Copy link
Member

Ma27 commented Aug 15, 2020

To documentation of builtins.fetchGit, but that change does not seem to be there in current docs:
https://nixos.org/nix/manual/#ssec-builtins

I assume this isn't backported to Nix 2.3? IIRC nixos.org always provides the docs of the latest stable release.

Maybe @Ma27 knows more about this issue, having worked on fetchTree?

Well, one could change the logic of the git-support in libfetchers:

nix/src/libfetchers/git.cc

Lines 353 to 356 in 839f0fe

auto ref = input.getRef();
auto fetchRef = ref->compare(0, 5, "refs/") == 0
? *ref
: "refs/heads/" + *ref;

However I think that theremarks @jakubgs brought up are quite reasonable. If we add those arguments those should be "translated" to "refs/{heads,tags}/foo" in the fetchGit primop[1]

[1]

static void prim_fetchGit(EvalState &state, const Pos &pos, Value **args, Value &v)
{
fetchTree(state, pos, args, v, "git", true);
}

@stale
Copy link

stale bot commented Feb 12, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 12, 2021
@jakubgs
Copy link
Author

jakubgs commented Feb 12, 2021

As far as I know this is still an issue.

@stale stale bot removed the stale label Feb 12, 2021
@stale
Copy link

stale bot commented Aug 17, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Aug 17, 2021
@jakubgs
Copy link
Author

jakubgs commented Aug 17, 2021

Nope.

@stale stale bot removed the stale label Aug 17, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Apr 16, 2022
@jakubgs
Copy link
Author

jakubgs commented Apr 16, 2022

Still a regression.

@stale stale bot removed the stale label Apr 16, 2022
@balsoft balsoft linked a pull request Jul 5, 2022 that will close this issue
@balsoft
Copy link
Member

balsoft commented Jul 5, 2022

See #6766

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/git-tags-in-flakes-inputs/25511/2

@stale stale bot removed the stale label May 10, 2023
@dpc
Copy link

dpc commented Dec 12, 2023

This is a painful paper-cut, especially combined with the proclivity of Nix to ignore any problems with inputs. It will silently fail to do the weird "shallow-semi-automated-update" and just move on with the old lock file content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants