python-rye icon indicating copy to clipboard operation
python-rye copied to clipboard

`uv self update` command cannot be used inside the devcontainer

Open gbaian10 opened this issue 11 months ago • 4 comments

I recently started learning to use devcontainer, and this repo has taught me a lot.


The UV built and copied into the container in multiple stages cannot execute the uv self update command.

If continue with the current approach, rebuilding the entire devcontainer might be the only way to upgrade the UV version?

I ultimately chose to use onCreateCommand to install UV, so I can use uv self update to upgrade the UV version.

"onCreateCommand": "curl -LsSf https://astral.sh/uv/install.sh | sh",
"updateContentCommand": "uv self update",
"postCreateCommand": "uv sync --frozen",

Also, I'm not quite sure about the trigger timing for updateContentCommand, so I'm not sure if writing it this way is correct.


I wonder if you think the approach mentioned above is appropriate?

gbaian10 avatar Feb 06 '25 14:02 gbaian10

Thank you for your issue!

If the following settings are made, uv self update command can be executed, but this time it is not recommended because it will cause a bug that prevents the installation of certain libraries.

"onCreateCommand": "curl -LsSf https://astral.sh/uv/install.sh | sh",
"updateContentCommand": "uv self update",
"postCreateCommand": "uv sync --frozen",

As you point out, uv self update command is not expected in this repository. I used ghcr.io/astral-sh/uv image, so I'm waiting for the image side to be supported.

Therefore, I recommend upgrading uv by restarting the devcontainer as is.

a5chin avatar Feb 07 '25 10:02 a5chin

It will cause a bug that prevents the installation of certain libraries.

Is there an example that package can be built using image copy, but cannot be built using command install?

gbaian10 avatar Feb 07 '25 13:02 gbaian10

For example, an error occurred when executing the following command (I have the impression that there are many ML-related library installations) was executed. As I recall, the error message was something along the lines of “Cargo is not installed”.

uv add transformers[ja,sentencepiece,torch]

a5chin avatar Feb 08 '25 13:02 a5chin

I've recently encountered a similar issue, but copying from the Dockerfile still didn't resolve it.

uv add py-rust-stemmers

The error message indicates that cargo cannot be found.

  × Failed to build `py-rust-stemmers==0.1.3`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `maturin.build_wheel` failed (exit status: 1)

      [stdout]
      Running `maturin pep517 build-wheel -i /home/vscode/.cache/uv/builds-v0/.tmpZrZr2G/bin/python --compatibility off`

      [stderr]
      💥 maturin failed
        Caused by: Cargo metadata failed. Do you have cargo in your PATH?
        Caused by: No such file or directory (os error 2)
      Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/home/vscode/.cache/uv/builds-v0/.tmpZrZr2G/bin/python', '--compatibility', 'off'] returned non-zero exit status 1

      hint: This usually indicates a problem with the package or the build environment.

gbaian10 avatar Feb 08 '25 14:02 gbaian10

I've set the uv version to latest in docker-compose.yml, so I'm closing this issue. Thank you for your issue!

a5chin avatar Nov 14 '25 01:11 a5chin