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 produces confusing error message for some (invalid) URLs #4711

Open
sheijk opened this issue Apr 15, 2021 · 3 comments
Open

fetchGit produces confusing error message for some (invalid) URLs #4711

sheijk opened this issue Apr 15, 2021 · 3 comments

Comments

@sheijk
Copy link

sheijk commented Apr 15, 2021

Describe the bug

When passing the following expression containing an error (a missing / at the end of the url):

let emacsOverlay = (import (builtins.fetchGit {
      url = "https://github.com/nix-community/emacs-overlay";
      ref = "master";
      rev = "47acbeca3e13a03131a0a7a9a3bd3443e1760d71";
    }));
in
# [...]

This is the error messages I'm seeing

warning: refname ‘47acbeca3e13a03131a0a7a9a3bd3443e1760d71’ is ambiguous. Git normally never creates a ref that ends with 40 hex characters because it will be ignored when you just specify 40-hex. These refs may be created by mistake. For example,

    git switch -c $br $(git rev-parse …)

where “$br” is somehow empty and a 40-hex ref is created. Please examine these refs and maybe delete them. Turn this message off by running “git config advice.objectNameWarning false”

Steps To Reproduce

  • Put above into a default.nix
  • Call nix-shell

Expected behavior

A more clear error message hinting at the real issue. Maybe even have a look if there is a bug lurking as it looks as if the rev value is treated as a branch name

nix-env --version output
nix-env (Nix) 2.3.10

Using 20.09 channel

@sheijk sheijk added the bug label Apr 15, 2021
@sheijk
Copy link
Author

sheijk commented Apr 20, 2021

Another confusing error message with this default.nix. The error here is that ref should be "refs/tags/1.0.4" instead of "1.0.4"

with import <nixpkgs> { };

let unused = builtins.fetchGit {
    url = "https://github.com/craigmbooth/nix-visualize.git/";
    # rev = "9efca80d83431a47024d363d270abff66a9491b6";
    ref = "1.0.4";
  };
in
unused

producing

error: cannot update ref 'refs/heads/1.0.4': trying to write non-commit object a6b1577ad37c77947a33302cdf4d9cf617ad27ce to branch 'refs/heads/1.0.4'
error: program 'git' failed with exit code 1

This only happens if a tag with this name exists. If the tag is completely wrong I get the much clearer error message

fatal: couldn't find remote ref 999
error: program 'git' failed with exit code 128

so it seems like there is some error check missing. Maybe it was introduced when fetchGit started automatically adding prefix to rev?

@milahu
Copy link
Contributor

milahu commented Sep 3, 2021

warning: refname ... is ambiguous.

these warnings come from git/object-name.c, may be a bug in builtins.fetchGit

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants