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

Latest release is not a static executable on Linux #107

Open
Mange opened this issue Apr 29, 2024 · 2 comments
Open

Latest release is not a static executable on Linux #107

Mange opened this issue Apr 29, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Mange
Copy link

Mange commented Apr 29, 2024

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.

@Mange
Copy link
Author

Mange commented Apr 29, 2024

(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

@JasonShin
Copy link
Owner

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

@JasonShin JasonShin added the bug Something isn't working label Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants