astral-sh / rye

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

warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance. If this is intentional, use `--link-mode=copy` to suppress this warning. #1262

Closed impredicative closed 2 months ago

impredicative commented 2 months ago

When running rye sync --update-all, I got the warning:

warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance. If this is intentional, use `--link-mode=copy` to suppress this warning.

To set the background, my project is is using devcontainer. As such, the cache dir may be in the container. The project dir however is outside the container, but is mapped into the container. This explains why the hardlink fails.

My issues are:

  1. Just to see, I tried specifying --link-mode=copy, but it wasn't accepted as a valid argument. It is not clear where or how to specify it.
  2. I don't really want to map the rye cache dir outside the container because I want good project isolation.
  3. rye could ideally detect the env var REMOTE_CONTAINERS=true, and if it sees this, it should not emit the warning.
  4. I don't want to explicitly declare in pyproject.toml that the project is container-based because it's up to the user of the project how they want to run it.
charliermarsh commented 2 months ago

You can set UV_LINK_MODE=copy in your container.

impredicative commented 2 months ago

I have now defined it in my project's .devcontainer/devcontainer.json file as:

    "containerEnv": {
        "UV_LINK_MODE": "copy"
    },
charliermarsh commented 2 months ago

Yeah it's a bit tedious but right now only a subset of the uv arguments are exposed on Rye's command-line. Perhaps we should have a blanket --uv-args thing.

impredicative commented 2 months ago

In my case, an env var is exactly what I needed, as I can define it at the container level. I didn't want to have to define anything at the project level. Alternatively, a global setting could have also worked.

charliermarsh commented 2 months ago

👍 For posterity, we define all respected environment variables here: https://github.com/astral-sh/uv?tab=readme-ov-file#environment-variables