Latest release is not a static executable on Linux
Hi! I decided to test out this library, but I cannot run it on my OS because the executable is dynamically linked[1].
The readme claims
Linux and Windows binaries are static executables.
However, the downloaded artifact (both using npm install and manually downloading the sqlx-ts-v0.11.1-linux-64-bit.zip release) yields a dynamically linked executable:
$ file ./sqlx-ts
./sqlx-ts: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=bb0c9104d6514a78884270594dce4c2fba41ba88, for GNU/Linux 3.2.0, with debug_info, not stripped
I don't see any setup to build against ex. musl to get a statically linked library, so I'm wondering if perhaps I misunderstood "static executable" and it means "precompiled executable" in this case.
Is there a way to get the Node install to compile the library locally instead of using a precompiled binary?
[1]: I use NixOS, which does not provide a global libc. Each executable must be statically linked or be compiled inside the NixOS env.
(This comment is not related to the issue at hand, but it might've used enough keywords that users with the same issue finds this issue in the future.)
If someone else has issues with this and are using NixOS, here's how I solved it: I patched the included binary with patchelf. Every time I update the dependency I will have to re-apply the patch, but it's not too bad.
The approach is to get patchelf to list the intepreter of something else you've got installed, then setting that interpreter in the binary.
https://github.com/Mange/dotfiles/blob/00242b772e362f531d4ed7998b9a141f2d3d54d9/bin/autopatchelf#L22-L27
tl;dr:
nix-shell -p patchelf
patchelf --set-interpreter "$(patchelf --print-interpreter "$(which cat)")" node_modules/sqlx-ts/sqlx-ts
Hello @Mange thanks for trying out the library and the issues raised - I also appreciate if you can send a PR of the improvements that you have raised