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

NixOS: Receiving an error of command failed when attempting to utilize the plugin on a fresh install. #286

Open
saurin-tech opened this issue Aug 30, 2023 · 4 comments
Labels
musl / nixos / alpine workaround exists There is a workaround for this already

Comments

@saurin-tech
Copy link

I'm attempting to use the plugin with gradle version of 7.6 but I'm running into the error shown below.

Task :b:npmInstall FAILED
npm ERR! code 127
npm ERR! path /home/dev/a/b/c/node_modules/@swc/core
npm ERR! command failed
npm ERR! command sh -c node postinstall.js
npm ERR! sh: line 1: /home/dev/a/b/c/.gradle/nodejs/node-v18.17.1-linux-x64/bin/node: cannot execute: required file not found

npm ERR! A complete log of this run can be found in: x.log

Contents of x.log file

verbose stack Error: command failed
1083 verbose stack     at ChildProcess.<anonymous> (/home/dev/a/b/c/.gradle/nodejs/node-v18.17.1-linux-x64/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
1083 verbose stack     at ChildProcess.emit (node:events:514:28)
1083 verbose stack     at maybeClose (node:internal/child_process:1091:16)
1083 verbose stack     at Socket.<anonymous> (node:internal/child_process:449:11)
1083 verbose stack     at Socket.emit (node:events:514:28)
1083 verbose stack     at Pipe.<anonymous> (node:net:323:12)
1084 verbose pkgid @swc/[email protected]
1085 verbose cwd /home/dev/a/b/c
1086 verbose Linux 6.1.49
1087 verbose node v18.17.1
1088 verbose npm  v9.6.7
1089 error code 127
1090 error path /home/dev/a/b/c/node_modules/@swc/core
1091 error command failed
1092 error command sh -c node postinstall.js
1093 error sh: line 1: /home/dev/a/b/c/.gradle/nodejs/node-v18.17.1-linux-x64/bin/node: cannot execute: required file not found
1094 verbose exit 127
1095 timing npm Completed in 11972ms
1096 verbose unfinished npm timer reify 1693431512159
1097 verbose unfinished npm timer reify:build 1693431523676
1098 verbose unfinished npm timer build 1693431523676
1099 verbose unfinished npm timer build:deps 1693431523676
1100 verbose unfinished npm timer build:run:postinstall 1693431523683
1101 verbose unfinished npm timer build:run:postinstall:node_modules/@swc/core 1693431523683
1102 verbose unfinished npm timer build:run:postinstall:node_modules/esbuild 1693431523711
1103 verbose code 127
1104 error A complete log of this run can be found in: /home/dev/.npm/_logs/2023-08-30T21_38_31_938Z-debug-0.log

contents of the build.gradle.kts file

import com.github.gradle.node.npm.task.NpmTask

plugins {
    id("com.github.node-gradle.node")
}

// Configure the plugin to download and use specific Node version
node {
    version.set("18.17.1")
    npmInstallCommand.set("install")
    download.set(true)
}

// Register NpmTask that will do what "npm run build" command does.
tasks.register<NpmTask>("npmBuild") {
    dependsOn(listOf("npmInstall"))
    npmCommand.set(listOf("run","build"))
    inputs.dir("src")
}

tasks.named<NpmTask>("npmInstall") {
    args.set(listOf("--loglevel verbose"))
}

Gradle output shows error caused by statement shown below

Caused by: org.gradle.process.internal.ExecException: Process 'command '/home/dev/a/b/c/.gradle/nodejs/node-v18.17.1-linux-x64/bin/npm'' finished with non-zero exit value 127

Thank you in advance!

@deepy
Copy link
Member

deepy commented Aug 31, 2023

Are you able to check if the /home/dev/a/b/c/.gradle/nodejs/node-v18.17.1-linux-x64/bin/node file exists and if the nodeSetup task finished successfully?
And then just to confirm, you're not on Alpine or another musl-based system right?

@saurin-tech
Copy link
Author

> Task :a:clean UP-TO-DATE
> Task :b:nodeSetup UP-TO-DATE
> Task :b:npmSetup SKIPPED
> Task :b:npmInstall

File does exist at the location listed above but when I try to execute it in terminal I receive an error zsh: no such file or directory:

I'm trying to run this on NixOS

@deepy
Copy link
Member

deepy commented Sep 1, 2023

Ah, well I've got good and bad news for you.
The bad news is you're gonna have to do some changes, but the good news I recently installed NixOS and have a basic idea of what those are 😀

You're going to need either a FHS or use something like nix-ld (or the very heavy approach of steam-run).
Personally I'm using nix-ld together with nix-direnv to set what I need to work on this project.
Unfortunately I need to run that flake with --impure since I don't know how to do that "properly", but this works well enough for me

NIX_LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath [
pkgs.stdenv.cc.cc.lib
];
NIX_LD = nixpkgs.lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker";

Basically it's the same issue as with musl, if you run ldd on the node binary you'll see that it's expecting glibc and it's not being found

@deepy deepy changed the title Receiving an error of command failed when attempting to utilize the plugin on a fresh install. NixOS: Receiving an error of command failed when attempting to utilize the plugin on a fresh install. Sep 1, 2023
@deepy deepy added musl / nixos / alpine workaround exists There is a workaround for this already labels Sep 1, 2023
@deepy
Copy link
Member

deepy commented Sep 1, 2023

And technically there's nothing this plugin can do to accommodate NixOS, this is a conscious decision from their project and while this may be awkward from the perspective of users there's several workarounds
Before I made the flake above I just ran steam-run zsh before developing and that worked mostly great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
musl / nixos / alpine workaround exists There is a workaround for this already
Projects
None yet
Development

No branches or pull requests

2 participants