thiagokokada/nix-alien

Should work with .sh files

Closed this issue · 2 comments

I want to use JetBrains' EP versions of their products. Link: https://www.jetbrains.com/resources/eap/. They deliver a .tar.gz file, which contains bin/idea.sh. When starting nix-alien with that, the result is:

err:
	not a dynamic executable

This error message is very correct. In the end, that script executes jbr/bin/java, which outputs

jbr/bin/java: You are trying to run an unpatched binary on nixos, but you have not configured NIX_LD or NIX_LD_x86_64-linux. See https://github.com/Mic92/nix-ld for more details

Executing that works:

nix --extra-experimental-features "nix-command flakes" run github:thiagokokada/nix-alien -- jbr/bin/java

But it misses the output:

Usage: java [options] <mainclass> [args...]
           (to execute a class)

When using sh -x, I can see the parameters which need to be passed to java. Then, I use nix-alien, but that misses libXext.so.6 somehow:

kotlinx.coroutines.JobCancellationException: Parent job is Cancelling; job=UndispatchedCoroutine{Cancelling}@61f6e43e

Caused by: java.lang.UnsatisfiedLinkError: /home/koppor/idea-IU-233.13135.103/jbr/lib/libawt_xawt.so: libXext.so.6: cannot open shared object file: No such file or directory


I wished, I could use nix-alien together with an sh file and that nix-alien "just" runs the script and if a binary is executed, that binary is executed using nix-alien.

I know, that could maybe not solve my issue as nix-alien won't fix the Java runtime behavior to look for shared libraries and throw an exception if not found.

Nothing we can do.

Analyzing dependencies inside scripting languages (not just Shell, also things like Python, Ruby, Lua, etc.) is basically impossible since we would need to have a deep understanding on each language (e.g.: knowing that to run a program in Python we can call subprocess.run, but also os.system and others).

The only reason nix-alien works so well for binaries is because they have a well designed mechanism to indicate their dependency (e.g.: ELF metadata), but even this can be bypassed by things like dlopen.

The only reason nix-alien works so well for binaries is because they have a well designed mechanism to indicate their dependency (e.g.: ELF metadata), but even this can be bypassed by things like dlopen.

And this is the reason that nix-alien is missing libXext.so.6, java probably loads this library dynamically and there is nothing we can do except maybe doing a deep analysis of the binary itself (but this is error prone).