Apparently IntelliJ IDEA (from nixpkgs) can’t install its own JDK for some reason and I might have to install and point to it manually.
This has led me to the titles question.
Also this has led me to believe that the same problem occurs in my Android Studio emulator problem (since I would get the same error as below when trying to run the emulator manually)
P.S.: Here’s the error from the failing IDEA Java execution:
/home/ari/.jdks/jbr-17.0.9/bin/java’: No such file or directory
For now the solution seems to be to download the desired JDK from nixpkgs, find it in the /nix/store, add its path (with /lib/openjdk appended to it) to the SDK section of Platform Settings inside Project Stucture and choose this new SDK in Project Settings in order to use it.
Doesn’t sound good to me - this path will get lost when you update your system and you’d collect garbage. You could achieve the exact same experience with using the desired JDK in environment.systemPackages, and use the path from /run/current-system/sw/bin/java.
Also if you don’t want to make it globally available, because it is a too specific JDK, you could also use something like this in your system configuration:
You are talking about the Nix attribute jetbrains.idea right?
Interesting… Could you try and run the same ldd command, from within the IDE? I’m sure there is a Bash shell option there or alike Inside it you should have the $LD_LIBRARY_PATH including zlib, according to:
And that indeed appears to be set by $LD_LIBRARY_PATH :
From IDE ❯ echo $LD_LIBRARY_PATH
/nix/store/bqwpsy99nbgp918w3mwn73jygm1i5ck4-zlib-1.3.1/lib:/nix/store/j2k44gyws2wlx3xrkv54zv0nhjihr0a5-pipewire-1.0.1-jack/lib
Yes that makes sense. Then what happens when you try to run that java from that IDE shell? Does it also give the No such file or directory error as reported originally?
So I guess the solution is to manage the SDKs through additional Nix configuration (as pointed by you) and not rely on JetBrains’ installations for now.
Yes I guess so… It is indeed one of the drawbacks of NixOS, that sometimes it’s impossible to further investigate why these outside-world binaries won’t run…
In your case, I suspect that this java executable executes other binaries from somewhere, that have missing libraries, like I suspected zlib to be a missing library. The way to further debug this is to run strace ~/.jdks/jbr-17.0.9/bin/java and find out what happens there. I’m not familiar with this kind of debugging so I won’t be able to further help.
If you will find the binary with the missing library, I’d be glad to help review a PR to Nixpkgs.
Anyways, thanks for all of the info you’ve provided. Was a pleasure interacting with you. And I’ll probably not look into strace unless I run into more problems.