dom96 / choosenim

Tool for easily installing and managing multiple versions of the Nim programming language.
BSD 3-Clause "New" or "Revised" License
679 stars 67 forks source link

Binary with hard-coded /lib64/ld-linux-x86-64.so.2 path #319

Open mimame opened 1 year ago

mimame commented 1 year ago

This happens with NixOS

When I run curl https://nim-lang.org/choosenim/init.sh -sSf | sh

choosenim-init: Downloading choosenim-0.8.4_linux_amd64
main: line 77: /tmp/cn/choosenim-0.8.4_linux_amd64: No such file or directory

After some investigations, I realized the next: ldd choosenim-0.8.4_linux_amd64

linux-vdso.so.1 (0x00007fff77de9000)
        libm.so.6 => /nix/store/9xfad3b5z4y00mzmk2wnn4900q0qmxns-glibc-2.35-224/lib/libm.so.6 (0x00007f81cee39000)
        librt.so.1 => /nix/store/9xfad3b5z4y00mzmk2wnn4900q0qmxns-glibc-2.35-224/lib/librt.so.1 (0x00007f81cee34000)
        libdl.so.2 => /nix/store/9xfad3b5z4y00mzmk2wnn4900q0qmxns-glibc-2.35-224/lib/libdl.so.2 (0x00007f81cee2f000)
        libc.so.6 => /nix/store/9xfad3b5z4y00mzmk2wnn4900q0qmxns-glibc-2.35-224/lib/libc.so.6 (0x00007f81cec00000)
        /lib64/ld-linux-x86-64.so.2 => /nix/store/9xfad3b5z4y00mzmk2wnn4900q0qmxns-glibc-2.35-224/lib64/ld-linux-x86-64.so.2 (0x00007f81cef1b000)

When I compile choosenim by myself, I get the good path: ldd choosenim

linux-vdso.so.1 (0x00007ffd309c4000)
        libm.so.6 => /nix/store/c35hf8g5b9vksadym9dbjrd6p2y11m8h-glibc-2.35-224/lib/libm.so.6 (0x00007fb8ebd48000)
        librt.so.1 => /nix/store/c35hf8g5b9vksadym9dbjrd6p2y11m8h-glibc-2.35-224/lib/librt.so.1 (0x00007fb8ebd43000)
        libdl.so.2 => /nix/store/c35hf8g5b9vksadym9dbjrd6p2y11m8h-glibc-2.35-224/lib/libdl.so.2 (0x00007fb8ebd3e000)
        libc.so.6 => /nix/store/c35hf8g5b9vksadym9dbjrd6p2y11m8h-glibc-2.35-224/lib/libc.so.6 (0x00007fb8eba00000)
        /nix/store/c35hf8g5b9vksadym9dbjrd6p2y11m8h-glibc-2.35-224/lib/ld-linux-x86-64.so.2 => /nix/store/9xfad3b5z4y00mzmk2wnn4900q0qmxns-glibc-2.35-224/lib64/ld-linux-x86-64.so.2 (0x00007fb8ebe2a000)

I don't know if this can be solved, but to I hope to be useful in any case

Thanks so much in advance

xTrayambak commented 10 months ago

Can confirm. I've tried this out too and the same error occurs.

daylinmorgan commented 9 months ago

You can try to get around this using nix-ld

I include the following in my nixos configuration:

...
  programs.nix-ld.enable = true;
  programs.nix-ld.libraries = with pkgs; [
    stdenv.cc.cc
    curl # for choosenim
  ];
...
daylinmorgan commented 9 months ago

Though while nix-ld helps to run binaries that were linked with /lib64/ld-linux-x86-64. I think it will create problems down the road running anything that relies on dynlib. I just found out I get runtime errors after compiling with -d:ssl. I don't have this issue with the nim2 package in nixpkgs though.