NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.39k stars 14.34k forks source link

metabase: Cannot run program "java": error=2, No such file or directory #227651

Open kevincox opened 1 year ago

kevincox commented 1 year ago

Describe the bug

Starting the Metabase NixOS service fails.

Caused by: java.io.IOException: Cannot run program "java": error=2, No such file or directory
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
        at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
        at java.base/java.lang.Runtime.exec(Runtime.java:592)
        at clojure.java.shell$sh.invokeStatic(shell.clj:113)
        at clojure.java.shell$sh.doInvoke(shell.clj:79)
        at clojure.lang.RestFn.invoke(RestFn.java:619)
        at metabase.db.update_h2$update_BANG_.invokeStatic(update_h2.clj:75)
        at metabase.db.update_h2$update_BANG_.invoke(update_h2.clj:68)
        at metabase.db.update_h2$update_if_needed.invokeStatic(update_h2.clj:98)
        at metabase.db.update_h2$update_if_needed.invoke(update_h2.clj:90)
        at metabase.db.data_source.DataSource.getConnection(data_source.clj:29)
        at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)
        at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:213)
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1176)
        at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1163)
        at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
        at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1908)
        at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)

Full log: metabase.log

Steps To Reproduce

Steps to reproduce the behavior:

  1. Have an h1 metabase database
    services.metabase = {
        enable = true;
        listen.ip = "localhost";
    };

Expected behavior

The service starts.

Additional context

This could probably be mitigated by adding java to the service path, but ideally the package itself would be patched to avoid replying on the PATH (maybe using a wrapper if required).

Maybe related to https://github.com/NixOS/nixpkgs/pull/225033/files

Notify maintainers

@schneefux @thoughtpolice @mmahut

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

kevincox commented 1 year ago

It appears this can be mitigated by adding the JDK into the service path. After migration it appears that this can be removed again.

    systemd.services.metabase.path = [pkgs.jdk11];

It also appears that this ends up downloading code to do the migration. Ideally that could would be downloaded at build time and included in the package.

tomodachi94 commented 2 weeks ago

This is peculiar. The wrapper executes the JAR using jdk11: https://github.com/NixOS/nixpkgs/blob/efdd0dd6f08801860ecad75a3a81d2dba7e51191/pkgs/servers/metabase/default.nix#L18

And the module simply executes that wrapper: https://github.com/NixOS/nixpkgs/blob/efdd0dd6f08801860ecad75a3a81d2dba7e51191/nixos/modules/services/misc/metabase.nix#L95

I wonder if we should be adding jdk11 to PATH in the wrapper, then having it use java without using its store path.