-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Attempting to coerce a list to a string may fail with confusing error "cannot coerce a set/function to a string" #4000
Comments
I marked this as stale due to inactivity. → More info |
i got stdenv.mkDerivation {
someFunction = x: x;
} mkDerivation hidden in abstractions# nix-build test.nix
with import <nixpkgs> {};
let
npmlock2nix = rec {
node_modules = # TRACE 7
{ src
, lockfilePostprocess ? x: x
, ...
}
@ args # TRACE 8
:
let
lockfile = lockfilePostprocess {};
in
stdenv.mkDerivation ( # TRACE 9
{
version = lockfile.version;
pname = lockfile.name;
}
//
args # TRACE 10
);
build = # TRACE 3
{ src
, node_modules_attrs ? {} # TRACE 4
}:
node_modules ( # TRACE 6
{ inherit src; }
//
node_modules_attrs # TRACE 5
);
};
in
npmlock2nix.build rec { # TRACE 2
src = /tmp;
node_modules_attrs = {
# the function lockfilePostprocess will cause the error:
# cannot coerce a function to a string
# cos attributes for derivation must be strings
# to reproduce the bug, lockfilePostprocess is NOT removed
# via cleanArgs in npmlock2nix/internal.nix
lockfilePostprocess = lockfileSet: ( # TRACE 1
lockfileSet // {
version = "1.2.3";
name = "some-package";
}
);
};
}
or, as a proper fix:
|
I marked this as stale due to inactivity. → More info |
I hate when this error appears, it's confusing and the message doesn't help to solve the issue. The issue was that I did |
Describe the bug
Attempting to call
toString
on a list containing a set will produce the very confusing error:or a list containing a function:
This can take a long time to figure out the first time it happens, as it gives the impression that its calling the list itself a set or a function.
It's especially confusing when you have an expression where you think you have excluded sets and you still end up with the error in the else branch:
Steps To Reproduce
nix eval --expr 'toString [ (x: x) ]'
ornix eval --expr 'toString [ {} ]'
.Expected behavior
A more helpful error, such as
nix-env --version
outputThe text was updated successfully, but these errors were encountered: