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

Error on nix shell gradle2nix v2 #64

Closed
rgoulter opened this issue May 30, 2024 · 4 comments
Closed

Error on nix shell gradle2nix v2 #64

rgoulter opened this issue May 30, 2024 · 4 comments

Comments

@rgoulter
Copy link

rgoulter commented May 30, 2024

Running into an error when I try v2 branch of gradle2nix in a nix shell. #62

Something about libnative-platform.so.

Log included in collapsed details:

Log output for nix shell -L github:tadfisher/gradle2nix/v2
nix shell -L github:tadfisher/gradle2nix/v2
gradle2nix> Running phase: unpackPhase
gradle2nix> unpacking source archive /nix/store/gk4hk5g8v7zksj56m4gdf23v87y4xp7s-source
gradle2nix> source root is source
gradle2nix> Running phase: patchPhase
gradle2nix> Running phase: updateAutotoolsGnuConfigScriptsPhase
gradle2nix> Running phase: configurePhase
gradle2nix> no configure script, doing nothing
gradle2nix> Running phase: buildPhase
gradle2nix> ++ export NIX_OFFLINE_REPO=/nix/store/6r515q0yzjglkryrk5279fyrb936bbzp-gradle2nix-2.0.0-gradle-repo
gradle2nix> ++ NIX_OFFLINE_REPO=/nix/store/6r515q0yzjglkryrk5279fyrb936bbzp-gradle2nix-2.0.0-gradle-repo
gradle2nix> ++ gradle --offline --no-daemon --no-build-cache --no-watch-fs --info --full-stacktrace --warning-mode=all --no-configuration-cache --console=plain -Dmaven.repo.local=/nix/store/6r515q0yzjglkryrk5279fyrb936bbzp-gradle2nix-2.0.0-gradle-repo --parallel --init-script /nix/store/w6n50fq75ch7a47pq66078hav3yks7h4-init.gradle installDist
gradle2nix> FAILURE: Build failed with an exception.
gradle2nix> * What went wrong:
gradle2nix> Gradle could not start your build.
gradle2nix> > Could not initialize native services.
gradle2nix>    > Failed to load native library 'libnative-platform.so' for Linux amd64.
gradle2nix> * Try:
gradle2nix> > Run with --debug option to get more log output.
gradle2nix> > Run with --scan to get full insights.
gradle2nix> > Get more help at https://help.gradle.org.
gradle2nix> * Exception is:
gradle2nix> org.gradle.initialization.exception.InitializationException: Gradle could not start your build.
gradle2nix>     at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:49)
gradle2nix>     at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:26)
gradle2nix>     at org.gradle.launcher.cli.DefaultCommandLineActionFactory$WithLogging.execute(DefaultCommandLineActionFactory.java:361)
gradle2nix>     at org.gradle.launcher.Main.doAction(Main.java:35)
gradle2nix>     at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:50)
gradle2nix>     at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
gradle2nix>     at java.base/java.lang.reflect.Method.invoke(Method.java:580)
gradle2nix>     at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
gradle2nix>     at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
gradle2nix>     at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
gradle2nix>     at java.base/java.lang.reflect.Method.invoke(Method.java:580)
gradle2nix>     at org.gradle.launcher.GradleMain.main(GradleMain.java:34)
gradle2nix> Caused by: org.gradle.internal.service.ServiceCreationException: Could not initialize native services.
gradle2nix>     at org.gradle.internal.nativeintegration.services.NativeServices.initialize(NativeServices.java:168)
gradle2nix>     at org.gradle.internal.nativeintegration.services.NativeServices.initializeOnClient(NativeServices.java:136)
gradle2nix>     at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:42)
gradle2nix>     at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:26)
gradle2nix>     at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:41)
gradle2nix>     ... 11 more
gradle2nix> Caused by: net.rubygrapefruit.platform.NativeException: Failed to load native library 'libnative-platform.so' for Linux amd64.
gradle2nix>     at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:67)
gradle2nix>     at net.rubygrapefruit.platform.Native.init(Native.java:56)
gradle2nix>     at org.gradle.internal.nativeintegration.services.NativeServices.initializeNativeIntegrations(NativeServices.java:179)
gradle2nix>     at org.gradle.internal.nativeintegration.services.NativeServices.initialize(NativeServices.java:164)
gradle2nix>     ... 15 more
gradle2nix> Caused by: java.io.IOException: No such file or directory
gradle2nix>     at java.base/java.io.UnixFileSystem.createFileExclusively0(Native Method)
gradle2nix>     at java.base/java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:258)
gradle2nix>     at java.base/java.io.File.createNewFile(File.java:1045)
gradle2nix>     at net.rubygrapefruit.platform.internal.NativeLibraryLocator.find(NativeLibraryLocator.java:45)
gradle2nix>     at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:45)
gradle2nix>     ... 18 more
error: builder for '/nix/store/k0ffa488fr2x6kmzs2w4b7db1j7jznnc-gradle2nix-2.0.0.drv' failed with exit code 1;
       last 10 log lines:
       >        at org.gradle.internal.nativeintegration.services.NativeServices.initialize(NativeServices.java:164)
       >        ... 15 more
       > Caused by: java.io.IOException: No such file or directory
       >        at java.base/java.io.UnixFileSystem.createFileExclusively0(Native Method)
       >        at java.base/java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:258)
       >        at java.base/java.io.File.createNewFile(File.java:1045)
       >        at net.rubygrapefruit.platform.internal.NativeLibraryLocator.find(NativeLibraryLocator.java:45)
       >        at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:45)
       >        ... 18 more
       >
       For full logs, run 'nix log /nix/store/k0ffa488fr2x6kmzs2w4b7db1j7jznnc-gradle2nix-2.0.0.drv'.
@tadfisher
Copy link
Owner

Interesting, does that happen with nix build?

@rgoulter
Copy link
Author

It does.

`nix -L build`
nix build -L github:tadfisher/gradle2nix/v2
gradle2nix> Running phase: unpackPhase
gradle2nix> unpacking source archive /nix/store/gk4hk5g8v7zksj56m4gdf23v87y4xp7s-source
gradle2nix> source root is source
gradle2nix> Running phase: patchPhase
gradle2nix> Running phase: updateAutotoolsGnuConfigScriptsPhase
gradle2nix> Running phase: configurePhase
gradle2nix> no configure script, doing nothing
gradle2nix> Running phase: buildPhase
gradle2nix> ++ export NIX_OFFLINE_REPO=/nix/store/6r515q0yzjglkryrk5279fyrb936bbzp-gradle2nix-2.0.0-gradle-repo
gradle2nix> ++ NIX_OFFLINE_REPO=/nix/store/6r515q0yzjglkryrk5279fyrb936bbzp-gradle2nix-2.0.0-gradle-repo
gradle2nix> ++ gradle --offline --no-daemon --no-build-cache --no-watch-fs --info --full-stacktrace --warning-mode=all --no-configuration-cache --console=plain -Dmaven.repo.local=/nix/store/6r515q0yzjglkryrk5279fyrb936bbzp-gradle2nix-2.0.0-gradle-repo --parallel --init-script /nix/store/w6n50fq75ch7a47pq66078hav3yks7h4-init.gradle installDist
gradle2nix> FAILURE: Build failed with an exception.
gradle2nix> * What went wrong:
gradle2nix> Gradle could not start your build.
gradle2nix> > Could not initialize native services.
gradle2nix>    > Failed to load native library 'libnative-platform.so' for Linux amd64.
gradle2nix> * Try:
gradle2nix> > Run with --debug option to get more log output.
gradle2nix> > Run with --scan to get full insights.
gradle2nix> > Get more help at https://help.gradle.org.
gradle2nix> * Exception is:
gradle2nix> org.gradle.initialization.exception.InitializationException: Gradle could not start your build.
gradle2nix>     at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:49)
gradle2nix>     at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:26)
gradle2nix>     at org.gradle.launcher.cli.DefaultCommandLineActionFactory$WithLogging.execute(DefaultCommandLineActionFactory.java:361)
gradle2nix>     at org.gradle.launcher.Main.doAction(Main.java:35)
gradle2nix>     at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:50)
gradle2nix>     at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
gradle2nix>     at java.base/java.lang.reflect.Method.invoke(Method.java:580)
gradle2nix>     at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
gradle2nix>     at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
gradle2nix>     at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
gradle2nix>     at java.base/java.lang.reflect.Method.invoke(Method.java:580)
gradle2nix>     at org.gradle.launcher.GradleMain.main(GradleMain.java:34)
gradle2nix> Caused by: org.gradle.internal.service.ServiceCreationException: Could not initialize native services.
gradle2nix>     at org.gradle.internal.nativeintegration.services.NativeServices.initialize(NativeServices.java:168)
gradle2nix>     at org.gradle.internal.nativeintegration.services.NativeServices.initializeOnClient(NativeServices.java:136)
gradle2nix>     at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:42)
gradle2nix>     at org.gradle.launcher.cli.NativeServicesInitializingAction.execute(NativeServicesInitializingAction.java:26)
gradle2nix>     at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:41)
gradle2nix>     ... 11 more
gradle2nix> Caused by: net.rubygrapefruit.platform.NativeException: Failed to load native library 'libnative-platform.so' for Linux amd64.
gradle2nix>     at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:67)
gradle2nix>     at net.rubygrapefruit.platform.Native.init(Native.java:56)
gradle2nix>     at org.gradle.internal.nativeintegration.services.NativeServices.initializeNativeIntegrations(NativeServices.java:179)
gradle2nix>     at org.gradle.internal.nativeintegration.services.NativeServices.initialize(NativeServices.java:164)
gradle2nix>     ... 15 more
gradle2nix> Caused by: java.io.IOException: No such file or directory
gradle2nix>     at java.base/java.io.UnixFileSystem.createFileExclusively0(Native Method)
gradle2nix>     at java.base/java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:258)
gradle2nix>     at java.base/java.io.File.createNewFile(File.java:1045)
gradle2nix>     at net.rubygrapefruit.platform.internal.NativeLibraryLocator.find(NativeLibraryLocator.java:45)
gradle2nix>     at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:45)
gradle2nix>     ... 18 more
error: builder for '/nix/store/k0ffa488fr2x6kmzs2w4b7db1j7jznnc-gradle2nix-2.0.0.drv' failed with exit code 1;
       last 10 log lines:
       >        at org.gradle.internal.nativeintegration.services.NativeServices.initialize(NativeServices.java:164)
       >        ... 15 more
       > Caused by: java.io.IOException: No such file or directory
       >        at java.base/java.io.UnixFileSystem.createFileExclusively0(Native Method)
       >        at java.base/java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:258)
       >        at java.base/java.io.File.createNewFile(File.java:1045)
       >        at net.rubygrapefruit.platform.internal.NativeLibraryLocator.find(NativeLibraryLocator.java:45)
       >        at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:45)
       >        ... 18 more
       >
       For full logs, run 'nix log /nix/store/k0ffa488fr2x6kmzs2w4b7db1j7jznnc-gradle2nix-2.0.0.drv'.

Ah, I should have mentioned. I'm on NixOS (23.11).

@rgoulter
Copy link
Author

rgoulter commented May 30, 2024

I think GRADLE_USER_HOME still needs to be set, even for newer gradle versions.

I was able to nix build . with this change.

diff --git a/gradle.nix b/gradle.nix
index 749e5fd..71a2849 100644
--- a/gradle.nix
+++ b/gradle.nix
@@ -316,13 +316,13 @@ let

         export NIX_OFFLINE_REPO='${offlineRepo}'

+        TMPHOME="$(mktemp -d)"
         ${optionalString (versionOlder finalAttrs.gradle.version "8.0") ''
           # Work around https://github.com/gradle/gradle/issues/1055
-          TMPHOME="$(mktemp -d)"
           mkdir -p "$TMPHOME/init.d"
-          export GRADLE_USER_HOME="$TMPHOME"
           cp ${initScript} $TMPHOME/
         ''}
+        export GRADLE_USER_HOME="$TMPHOME"

         gradle --offline --no-daemon --no-build-cache --no-watch-fs \
           --info --full-stacktrace --warning-mode=all \

@tadfisher
Copy link
Owner

Should be fixed in 44f193c; please re-open if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants