Skip to content

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

Closed

Description

@bjornfor

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.

Activity

  1. added 2 commits that reference this issue on Mar 27, 2021
    2464a92
    edd606a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions