rye icon indicating copy to clipboard operation
rye copied to clipboard

Interpreters don't work on NixOS

Open HitaloM opened this issue 10 months ago • 3 comments

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 [email protected]
Checking checksum
Unpacking
Downloaded [email protected]
error: unable to create self venv using /home/hitalo/.rye/py/[email protected]/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: [email protected]) symlink support: true uv enabled: false

HitaloM avatar Apr 01 '24 02:04 HitaloM

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.

dsp avatar Apr 02 '24 09:04 dsp

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.

HitaloM avatar Apr 04 '24 19:04 HitaloM

This command did the trick

$ rye toolchain register `which python3.11`
Registered /etc/profiles/per-user/not7cd/bin/python3.11 as [email protected]

not7cd avatar Jul 19 '24 08:07 not7cd