Problem to make Godot engine finding Java, is it Nixos specific?

Hello, I try to export a Godot project to Android.
I installed Android Studio and filled the required fields in the “editor settings”. The result is the apksigner error 126. It worked as expected on my previous OS.
According to a Stackoverflow post it is a problem with java. sdk - Godot 'apksigner' returned with error #126 - Stack Overflow But it is present in my configuration.nix as jdk11 and I tried successfully an hello world in Java.

I enabled these programs.
programs.adb.enable = true;
programs.java.enable = true;

and apksigner script is executable.

Advices are welcome.

Can you run head -n 1 on it and share the result? I’m going to guess the shebang is wrong. Otherwise maybe a binary it invokes has a broken interpreter.

See: Packaging/Binaries - NixOS Wiki, but I’ll happily help figure out what the actual problem is, just need to figure out what file isn’t “executable” first.

head -n 1 apksigner
#!/bin/bash

Thank you for the advice.

Change that line to

#!/usr/bin/env bash

NixOS doesn’t have /bin/bash, bash instead lives somewhere in /nix/store (and the location isn’t stable across updates). This is by design, and necessary for the reproducibility guarantees.

NixOS does give you /bin/sh, as that’s POSIX standard, as well as /usr/bin/env, which will find the interpreter using your $PATH, and almost certainly contains bash.

Unfortunately, lots of scripts assume bash is in /bin/bash because it’s common for it to be there across distros. Or because the author never thought too hard about it and they’ve seen that line in other people’s scripts. IME, you can almost always use /bin/sh, too, people rarely use bash’ extra features.

This also breaks e.g. on alpine, by the way, not just NixOS. Anything that doesn’t have bash in the same place as ubuntu, really.

1 Like
Hosted by Flying Circus.