How to deal w/ Java maven "install-node-and-npm" targets?

Hello,

I’m trying to run jhipster-lite, however it has a maven task (see below), that downloads a copy of nodejs to run within the project folder ./node/node.

      <plugin>
        <groupId>com.github.eirslett</groupId>
...
              <goal>install-node-and-npm</goal>
...
            <configuration>
              <nodeVersion>${node.version}</nodeVersion>
              <npmVersion>${npm.version}</npmVersion>
            </configuration>
...

The version of nodejs downloaded is not patched for Nix and so it fails to run as it cannot resolve libstdc++.so.6, if I try to prefix it sadly still doesn’t run (even though ldd says all libs resolve):

ls ./node
# ./node
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/nix/store/v8481v3a686aa0pa4d016c0lnz2j0wwb-gcc-11.3.0-lib/lib/ ./node
bash: ./node: No such file or directory

I’m wondering how folks generally deal with this, do they hack up the pom.xml or is there some magic that can be done to help this out?

Any help is appreciated :smiley:

EDIT: Steps to reproduce:

# Enable java for the system and nixos-rebuild switch:
#   programs.java.enable = true;
git clone https://github.com/jhipster/jhipster-lite
cd jhipster-lite
./mvnw spring-boot:build-image -Pnative

If you just want to build ‘interactively’, using buildFHSUserEnv in your shell.nix might be a good workaround.

There is some precedent for proposing upstream to explicitly use the nix linker to start commands inside the build (protoc-bridge/ProtocRunner.scala at f0610b4ebd702afd81c901264bd846f32e7f9f06 · scalapb/protoc-bridge · GitHub) so buildFHSUserEnv is not needed, but perhaps there is a more elegant way?

1 Like

Thanks for the reply …

At least to start, I think I’m going to try to run it containerized:

docker run --rm --pull=always -p 7471:7471 -v $(pwd):/tmp/jhlite:Z -it jhipster/jhipster-lite:latest

I expect the projects it generates will require that buildFHSUserEnv approach though as I don’t imagine a pure java project will want to accept nixos-specific customisations.

The general pattern for this type of thing is using any --offline flags and pre-populating the cache to avoid java or whatever going out to the internet for something.

Unfortunately it doesn’t fit the --offline model for producing jar/war/etc because it’s a hybrid application. I tried passing in --offline to maven and it still tried to start ./node/node :cry:

Well, I imagine a lenient definition of offline might include calling external processes without invoking that processes likely non-existent --offline flag.

My next step would be to answer:

“What maven configuration is causing ./node/node to be called?”