RyeをNixOS上で動かそうとしたときの記録(2024年2月)
更新内容 2024/09/14 これは2024年2月ごろにNixOS上でRyeを動かそうと悪戦苦闘したときの記録である。現在だと uv の登場でいろいろ変わっており、この記事の内容が再現しない可能性が高いので注意。 要約 NixOS外でビルドされたたいていのバイナリはリンカのパスが /lib/ や /lib64/ が前提であるようになっているが、NixOSにはこれがないのでそのままでは動かない 解決策としては以下のようになる nix-ldを導入する 共有ライブラリが足りないなどのエラーが出た場合は、LD_LIBRARY_PATHを指定する それでもうまく動かない場合はあるので、できればNix外のバイナリを使うのは避けたい 経緯 Pythonのプロジェクト管理ツールであるRyeを使いたくなった(もちろんNixOSを使っているんだからRyeを使わず全部nixファイルで管理しろ、と言われればその通りなのだが、手軽にパッケージや仮想環境を管理できるところに惹かれて使ってみたくなった) Ryeはまだ盛んに開発されており、まだまだ今後変わりうる可能性があるが、現バージョン(0.24.0)で試しに使ってみよう。nixの場合、以下のコマンドで一時的にRyeを入れて実行可能だ。 1 nix run nixpkgs#rye プロンプトに従って進めていく。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [bombrary@nixos:~/python/bin]$ nix run nixpkgs#rye Welcome to Rye! Rye has detected that it's not installed on this computer yet and automatically started the installer for you. For more information read https://rye-up.com/guide/installation/ This installer will install rye to /home/bombrary/.rye This path can be changed by exporting the RYE_HOME environment variable. Details: Rye Version: 0.24.0 Platform: linux (x86_64) ✔ Continue? · yes ✔ Select the preferred package installer · pip-tools (slow but stable) ✔ Determine Rye's python Shim behavior outside of Rye managed projects · Make Rye's own Python distribution available ✔ Which version of Python should be used as default toolchain? · cpython@3.12 ところが、最後のcpython@3.12.1のダウンロード後、No such file or directory という一見謎のエラーで終了する。 ...