astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.67k stars 467 forks source link

Interpreters don't work on NixOS #975

Open HitaloM opened 6 months ago

HitaloM commented 6 months ago

Steps to Reproduce

Just run rye sync or any other command that runs the python interpreter

Logs

Installed binary to /home/hitalo/.rye/shims/rye
Bootstrapping rye internals
Downloading cpython@3.12.2
Checking checksum
Unpacking
Downloaded cpython@3.12.2
error: unable to create self venv using /home/hitalo/.rye/py/cpython@3.12.2/bin/python3. It might be that the used Python build is incompatible with this machine. For more information see https://rye-up.com/guide/installation/

Caused by:
    No such file or directory (os error 2)

Version Info

rye 0.31.0 commit: 0.31.0 (1980-01-01) platform: linux (x86_64) self-python: not bootstrapped (target: cpython@3.12) symlink support: true uv enabled: false

dsp commented 6 months ago

The Python binaries we are currently distribution are relying on glibc and dynamic loading of libraries. The way NixOS works, we would either have to rely on a system python (which somewhat defeats the purpose of rye) or rely on static Python builds (with their own limitations).

NixOS is very specific about how they deal with dynamic loading. It is basically impossible to download a binary and have it "just work" (unless it's fully static), since NixOS binaries are either build within NixOS and directly refer to libraires in the nix store (/nix/...) or the elf is patched to find the right dynamic libray in the nix store (since /usr/lib, etc isn't populated).

I think it would be best for NixOS to provide it's own patched rye in nixpkgs, that relies on system python. Alternatively one would provide a set of nix expressions that allow for registering nixpkgs Python as rye toolchains. This way one could easily build a flake that pulls in NixOS Python packages. Notable, maybe you have luck with using a FHS environment with rye.

For now, I think (I am not the maintainer, so that's all Armin's call), given the nature of NixOS and software for NixOS, it is out of scope to support NixOS.

HitaloM commented 6 months ago

The Python binaries we are currently distribution are relying on glibc and dynamic loading of libraries. The way NixOS works, we would either have to rely on a system python (which somewhat defeats the purpose of rye) or rely on static Python builds (with their own limitations).

NixOS is very specific about how they deal with dynamic loading. It is basically impossible to download a binary and have it "just work" (unless it's fully static), since NixOS binaries are either build within NixOS and directly refer to libraires in the nix store (/nix/...) or the elf is patched to find the right dynamic libray in the nix store (since /usr/lib, etc isn't populated).

I think it would be best for NixOS to provide it's own patched rye in nixpkgs, that relies on system python. Alternatively one would provide a set of nix expressions that allow for registering nixpkgs Python as rye toolchains. This way one could easily build a flake that pulls in NixOS Python packages. Notable, maybe you have luck with using a FHS environment with rye.

For now, I think (I am not the maintainer, so that's all Armin's call), given the nature of NixOS and software for NixOS, it is out of scope to support NixOS.

Got it, thanks for the tip about using an FHS environment, I'll try to solve the problem for now.

not7cd commented 2 months ago

This command did the trick

$ rye toolchain register `which python3.11`
Registered /etc/profiles/per-user/not7cd/bin/python3.11 as cpython@3.11.6