Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

ruff is currently built from source in the nix flake, slowing down dev environment creation and requiring a moving rust version #15939

Open
anoadragon453 opened this issue Jul 14, 2023 · 3 comments
Labels
O-Uncommon Most users are unlikely to come across this or unexpected workflow T-Other Questions, user support, anything else. Z-Dev-Wishlist Makes developers' lives better, but doesn't have direct user impact Z-Upstream-Bug This issue requires a fix in an upstream dependency.

Comments

@anoadragon453
Copy link
Member

We have a flake.nix file which can be used to create a full development environment for Synapse, including python and native dependencies and things like postgres and redis.

The development environment will automatically keep its python environment up to date with poetry using the versions defined in pyproject.yaml. One of those python package is ruff, which we use as a linter.

ruff ships a rust binary, which is dynamically linked against either glibc or musl. As such, ruff expects glibc or muslc headers to exist at a certain location on your Linux box. Due to the way NixOS works, these do not exist under the expected path, causing any ruff binaries we download from PyPI to fail to execute.

Thus, we have the following workaround in flake.nix, which forces ruff to be compiled on the local system:

synapse/flake.nix

Lines 115 to 122 in 20ae617

# This is a work-around for NixOS systems. NixOS is special in
# that you can have multiple versions of packages installed at
# once, including your libc linker!
#
# Some binaries built for Linux expect those to be in a certain
# filepath, but that is not the case on NixOS. In that case, we
# force compiling those binaries locally instead.
env.POETRY_INSTALLER_NO_BINARY = "ruff";

This works, but is slow (as you need to compile a rust binary) and forces the development environment to maintain a rust version which is high enough to compile ruff (which unfortunately is almost always the latest stable. I found today that while we only require rust 1.60.0 in Synapse, the version of ruff we have specified in our pyproject.toml requires rust 1.70.0.

The ideal solution here is for ruff to provide statically linked binaries to download. This has been discussed in astral-sh/ruff#1699, and they are up for it if it does not compromise performance (or alternatively they could provide a ruff-static PyPI package.

Until then, we can't do much on this side.

@anoadragon453 anoadragon453 added Z-Upstream-Bug This issue requires a fix in an upstream dependency. T-Other Questions, user support, anything else. Z-Dev-Wishlist Makes developers' lives better, but doesn't have direct user impact O-Uncommon Most users are unlikely to come across this or unexpected workflow labels Jul 14, 2023
anoadragon453 added a commit that referenced this issue Jul 14, 2023
@anund
Copy link

anund commented Aug 19, 2023

You can find an example using patchelf/autopatchelf here astral-sh/ruff-pre-commit#22 (comment)

anoadragon453 added a commit that referenced this issue Sep 6, 2023
ruff has updated their minimum rust version, and due to
#15939, we have to
follow along.
@victorfernandesraton
Copy link

I have same issue but with pre-commit , i think is not a binary issues since ruff is in my enviroment

@anoadragon453
Copy link
Member Author

@victorfernandesraton could you elaborate on what you mean? We don't have any git pre-commit hooks in the Synapse repo.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
O-Uncommon Most users are unlikely to come across this or unexpected workflow T-Other Questions, user support, anything else. Z-Dev-Wishlist Makes developers' lives better, but doesn't have direct user impact Z-Upstream-Bug This issue requires a fix in an upstream dependency.
Projects
None yet
Development

No branches or pull requests

3 participants