-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Github dependencies fail with nix 2.4 #91
Comments
Does that also happen if you don't run the build through a flake? |
Yes |
This looks like a Nix regression then: # reproducer.nix
builtins.fetchGit {
ref = "db1442a0556c2b133627ffebf455a78a1ced64b9";
rev = "db1442a0556c2b133627ffebf455a78a1ced64b9";
url = "https://github.com/tmcw/leftpad";
} On stable (2.3) nix:
On the unstable (2.4) version of NIx:
So we went from a warning into a failure (instead of an explicit error from the Nix side). |
This comment has been minimized.
This comment has been minimized.
I encountered this issue as well with unstable Nix, and I tried using stable Nix with: $ nix shell nixpkgs#nixStable -c nix-build
warning: refname '4a54f56a25b58950f9e4277c56db2912d62242e7' 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"
error: [npmlock2nix] failed to parse GitHub reference `git+https://github.com/resin-io/bonjour.git#e018851dc823b4b3f670f658f71d0c1c7f3e637c`. Expected a string of format `github:org/repo#revision` But I don't understand why it fails.. The lock file is at: https://github.com/balena-io/balena-cli/blob/master/npm-shrinkwrap.json |
this format is used in npm7 lockfiles current npmlock2nix only understands function parseGitHubRef # Description: Takes a string of the format "github:org/repo#revision" and returns
# an attribute set { org, repo, rev }
# Type: String -> Set
parseGitHubRef = str:
if lib.hasPrefix "github:" str
then
let
parts = builtins.split "[:#/]" str;
in
assert !(builtins.length parts == 7) ->
throw "failed to parse GitHub reference `${str}`. Expected a string of format `github:org/repo#revision`";
rec {
inherit parts;
org = builtins.elemAt parts 2;
repo = builtins.elemAt parts 4;
rev = builtins.elemAt parts 6;
}
else
if lib.hasPrefix "git+ssh://git@github.com/" str # produced by npm v7 (dependency.version)
then
# git+ssh://git@github.com/milahu/postcss-nodegui-autoprefixer.git#263b0245164ae0ab10cd5abf31f2ad302c0ecec3
let
parts = builtins.split "[:#/]|(.git#)" str;
in
assert !(builtins.length parts == 13) ->
throw "failed to parse GitHub reference `${str}`. Expected a string of format `git+ssh://git@github.com/repo.git#revision`";
rec {
inherit parts;
org = builtins.elemAt parts 8;
repo = builtins.elemAt parts 10;
rev = builtins.elemAt parts 12;
}
else
if (builtins.match ".+@github:.+" str) != null # produced by npm v7 (dependency.from)
# postcss-nodegui-autoprefixer@github:milahu/postcss-nodegui-autoprefixer#263b0245164ae0ab10cd5abf31f2ad302c0ecec3
then
let
parts = builtins.split "[:#/]|(.git#)" (builtins.elemAt (builtins.split "@github:" str) 2);
in
assert !(builtins.length parts == 5) ->
throw "failed to parse GitHub reference `${str}`. Expected a string of format `name@github:org/repo#revision`. str2 = ${builtins.elemAt (builtins.split "@github:" str) 2}. num parts = ${toString (builtins.length parts)}";
rec {
inherit parts;
org = builtins.elemAt parts 0;
repo = builtins.elemAt parts 2;
rev = builtins.elemAt parts 4;
}
else
builtins.throw "failed to parse version: ${str}"
; |
Thanks for the clarification, it seems as if #94 helps this, but |
Adds `allRefs = true;` to the invocation of fetchGit as opposed to repassing the commit hash as the ref, which fails with nix version >=2.4 Fixes nix-community#91
Adds `allRefs = true;` to the invocation of fetchGit as opposed to repassing the commit hash as the ref, which fails with nix version >=2.4 Fixes #91
Describe the bug
Using nix 2.4 the github-dependency test case from the examples-projects fails with
fetching Git repository 'https://github.com/tmcw/leftpad'fatal: couldn't find remote ref refs/heads/db1442a0556c2b133627ffebf455a78a1ced64b9
.To Reproduce
package.json
package-lock.json
flake.nix
Then run
nix build
Expected behavior
The build succeeds.
Environment
The text was updated successfully, but these errors were encountered: