Closed winston0410 closed 2 years ago
I still get this error when I change the derivation to this, seems the error comes from npmlock2nix.node_modules
{ pkgs, lib, stdenv, npmlock2nix, ... }:
# https://github.com/prettier/plugin-pug
let
version = "743f5aafa11d161537bbcd614fe5af81944a8d2f";
src = pkgs.fetchFromGitHub {
owner = "winston0410";
repo = "plugin-pug";
rev = version;
sha256 = "sha256-SUH94XnD0a0JX3SQQmHB9SWnS7oVP9BiBcS9a7o4wm0=";
};
nodeModules = npmlock2nix.node_modules {
inherit src;
};
in (stdenv.mkDerivation {
pname = "prettier-plugin-pug";
inherit version src;
buildInputs = [ pkgs.nodejs ];
buildPhase = ''
echo ${nodeModules}
'';
installPhase = ''
echo "hello" > $out
'';
})
Can you please post the full log of the failing command?
@andir This is the full log. I cannot paste it out because it is too long. debug.log
This smells like $out
is unset when the install phase is hit (https://github.com/nix-community/npmlock2nix/blob/33eb3300561d724da64a46ab8e9a05a9cfa9264b/internal.nix#L382). Can you set postBuild
to echo $out
in the node_modules
call ?
I updated it to this:
{ pkgs, lib, stdenv, npmlock2nix, ... }:
# https://github.com/prettier/plugin-pug
let
version = "743f5aafa11d161537bbcd614fe5af81944a8d2f";
src = pkgs.fetchFromGitHub {
owner = "winston0410";
repo = "plugin-pug";
rev = version;
sha256 = "sha256-SUH94XnD0a0JX3SQQmHB9SWnS7oVP9BiBcS9a7o4wm0=";
};
nodeModules = npmlock2nix.node_modules {
inherit src;
};
in (stdenv.mkDerivation {
pname = "prettier-plugin-pug";
inherit version src;
buildInputs = [ pkgs.nodejs ];
buildPhase = ''
echo ${nodeModules}
'';
postBuild = ''
echo $out
'';
installPhase = ''
echo "hello" > $out
'';
})
And this is the error. Looks like the same to me. debug.log
The problem is in this line, which $out
is empty
https://github.com/nix-community/npmlock2nix/blob/33eb3300561d724da64a46ab8e9a05a9cfa9264b/internal.nix#L382
But this seems to be idiomatic nix? I think I have seen something similar in tutorials.
A repo for reproducing this issue: https://github.com/winston0410/build-nodejs
Try to fix this in this pr
This just happened to me as well.
The problem was caused by the name
attribute in package-lock.json
containing special characters (in my case @sephii/foobar
). I noticed the special characters @
and /
got replaced by ?
during the build process, This caused the mkdir command to fail, probably because the ?
characters got interpreted in some way? I changed the name
attribute to something without special characters and it fixed the problem, but I think either the $out
argument should be quoted, or the special characters in the package name shouldn’t be replaced by ?
. Edit: ah I didn’t check the PR, which came to the same conclusions.
@sephii Yes exactly. I hope they can merge it my PR to fix this.
I have this derivation:
And I got this error: