NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.4k stars 14.35k forks source link

Package rye depends on libz #315823

Open light4 opened 6 months ago

light4 commented 6 months ago

Describe the bug

Package rye depends on libz

Steps To Reproduce

Steps to reproduce the behavior:

  1. install rye
  2. rye init and rye sync
  3. got error

Expected behavior

rye sync success

Screenshots

light4@vegapunk ~/p/ChatTTS (main)> rye sync
Bootstrapping rye internals
Downloading cpython@3.12.3
Checking checksum
Unpacking
Downloaded cpython@3.12.3
Could not start dynamically linked executable: /home/light4/.rye/uv/0.1.44/uv
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld
error: could not sync because bootstrap failed

Caused by:
    Failed to create self venv using /home/light4/.rye/py/cpython@3.12.3/bin/python3. uv exited with status: exit status: 127

Stack backtrace:
   0: anyhow::error::<impl anyhow::Error>::msg
   1: rye::uv::Uv::venv
   2: rye::bootstrap::ensure_self_venv_with_toolchain
   3: rye::sync::sync
   4: rye::cli::sync::execute
   5: rye::cli::execute
   6: std::panicking::try
   7: rye::utils::panic::trap_bad_pipe
   8: rye::main
   9: std::sys_common::backtrace::__rust_begin_short_backtrace
  10: std::rt::lang_start::{{closure}}
  11: std::panicking::try
  12: std::rt::lang_start_internal
  13: main
  14: __libc_start_call_main
  15: __libc_start_main@@GLIBC_2.34
  16: _start
light4@vegapunk ~/p/ChatTTS (main) [1]> ldd /home/light4/.rye/uv/0.1.44/uv 
    linux-vdso.so.1 (0x00007ffd2f302000)
    libz.so.1 => not found
    libgcc_s.so.1 => /nix/store/1q9vc0lq7qjlfjz47mfmlzdf86c543jy-xgcc-13.2.0-libgcc/lib/libgcc_s.so.1 (0x00007f83cd20d000)
    librt.so.1 => /nix/store/k7zgvzp2r31zkg9xqgjim7mbknryv6bs-glibc-2.39-52/lib/librt.so.1 (0x00007f83cd208000)
    libpthread.so.0 => /nix/store/k7zgvzp2r31zkg9xqgjim7mbknryv6bs-glibc-2.39-52/lib/libpthread.so.0 (0x00007f83cd203000)
    libm.so.6 => /nix/store/k7zgvzp2r31zkg9xqgjim7mbknryv6bs-glibc-2.39-52/lib/libm.so.6 (0x00007f83caf1d000)
    libdl.so.2 => /nix/store/k7zgvzp2r31zkg9xqgjim7mbknryv6bs-glibc-2.39-52/lib/libdl.so.2 (0x00007f83cd1fc000)
    libc.so.6 => /nix/store/k7zgvzp2r31zkg9xqgjim7mbknryv6bs-glibc-2.39-52/lib/libc.so.6 (0x00007f83cad30000)
    /lib64/ld-linux-x86-64.so.2 => /nix/store/k7zgvzp2r31zkg9xqgjim7mbknryv6bs-glibc-2.39-52/lib64/ld-linux-x86-64.so.2 (0x00007f83cd234000)

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

light4@vegapunk ~/p/ChatTTS (main)> nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.8.9, NixOS, 24.11 (Vicuña), 24.11.20240527.9ca3f64`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - channels(root): `"home-manager, nixos"`
 - nixpkgs: `/nix/store/chfsb0gihh4qb9g6gr67dl46zl93mgd2-b2xy0gk6sd3fc8zamarfzach5f3wpkvi-source`

Add a :+1: reaction to issues you find important.

natsukium commented 6 months ago

fyi @GaetanLepage

GaetanLepage commented 6 months ago

Thanks for the report. This is a bit tricky indeed. rye is downloading (at runtime) its own version of the uv and python binaries which are of course not patched for use with NixOS. I don't see an easy way to fix this as the fundamental approach of rye is orthogonal to how NixOS works. rye adopts a "no asumption" approach by bundling everything "deterministically". Well, they are doing a single assumption: FHS compliance of the host system.

Maybe an FHS nix shell can work out. An other alternative would be to operate changes upstream letting the user the freedom of providing its own paths/binaries for uv/python, but again, this is exactly the contrary of what rye is trying to achieve.

anoadragon453 commented 5 months ago

I managed to work around this with patchelf. I placed the following in my development environment flake. It must be run after rye has downloaded a dynamically linked binary:

patchelf --set-interpreter ${pkgs.glibc}/lib/ld-linux-x86-64.so.2 $HOME/.rye/uv/*/uv
patchelf --set-interpreter ${pkgs.glibc}/lib/ld-linux-x86-64.so.2 $HOME/.rye/py/cpython@*/bin/python3

Unfortunately you have to run rye sync to download a binary, run the above, then rinse and repeat until all downloaded binaries have been patched.