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

builtins.fetchGit { ..., ref = "HEAD"; } wrongly tries to fetch "refs/heads/HEAD" #4674

Closed
bjornfor opened this issue Mar 26, 2021 · 0 comments · Fixed by #4676
Closed

builtins.fetchGit { ..., ref = "HEAD"; } wrongly tries to fetch "refs/heads/HEAD" #4674

bjornfor opened this issue Mar 26, 2021 · 0 comments · Fixed by #4676
Labels

Comments

@bjornfor
Copy link
Contributor

Describe the bug

Stable Nix 2.3.10 does it right:

$ nix repl
Welcome to Nix version 2.3.10. Type :? for help.

nix-repl> builtins.fetchGit { url = "https://github.com/NixOS/nix"; ref = "HEAD"; }
{ outPath = "/nix/store/32wd1lrf55ymaz1aysrqffpxfgkwl6m4-source"; rev = "dd77f71afe6733e9790dd001125c423cb648b7ce"; revCount = 10127; shortRev = "dd77f71"; }

But unstable Nix 2.4pre20210308_1c0e3e4 (latest nixUnstable in release-20.09) breaks if given ref = "HEAD":

$ ./result/bin/nix repl
Welcome to Nix version 2.4pre20210308_1c0e3e4. Type :? for help.

nix-repl> builtins.fetchGit { url = "https://github.com/NixOS/nix"; ref = "HEAD"; }
fetching Git repository 'https://github.com/NixOS/nix'fatal: couldn't find remote ref refs/heads/HEAD
error: program 'git' failed with exit code 128

Expected behavior
The documented default value of ref is HEAD, so Nix should also accept it when explicitly given. It works in stable Nix (2.3.10) but is broken in the latest nixUnstable code base.

Additional context

poetry2nix can end up calling builtins.fetchGit with ref = "HEAD", that's how I hit this issue.

@bjornfor bjornfor added the bug label Mar 26, 2021
bjornfor added a commit to bjornfor/nix that referenced this issue Mar 27, 2021
This fixes builtins.fetchGit { url = ...; ref = "HEAD"; }, that works in
stable nix (v2.3.10), but is broken in nix master:

  $ ./result/bin/nix repl
  Welcome to Nix version 2.4pre19700101_dd77f71. Type :? for help.

  nix-repl> builtins.fetchGit { url = "https://github.com/NixOS/nix"; ref = "HEAD"; }
  fetching Git repository 'https://github.com/NixOS/nix'fatal: couldn't find remote ref refs/heads/HEAD
  error: program 'git' failed with exit code 128

The documentation for builtins.fetchGit says ref = "HEAD" is the
default, so it should also be supported to explicitly pass it.

I came across this issue because poetry2nix can use ref = "HEAD" in some
situations.

Fixes NixOS#4674.
bjornfor added a commit to bjornfor/nix that referenced this issue Mar 30, 2021
This fixes builtins.fetchGit { url = ...; ref = "HEAD"; }, that works in
stable nix (v2.3.10), but is broken in nix master:

  $ ./result/bin/nix repl
  Welcome to Nix version 2.4pre19700101_dd77f71. Type :? for help.

  nix-repl> builtins.fetchGit { url = "https://github.com/NixOS/nix"; ref = "HEAD"; }
  fetching Git repository 'https://github.com/NixOS/nix'fatal: couldn't find remote ref refs/heads/HEAD
  error: program 'git' failed with exit code 128

The documentation for builtins.fetchGit says ref = "HEAD" is the
default, so it should also be supported to explicitly pass it.

I came across this issue because poetry2nix can use ref = "HEAD" in some
situations.

Fixes NixOS#4674.
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.

1 participant