Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support https://astral.sh/uv/install.sh running as Nobody #8242

Closed
VirtualTim opened this issue Oct 16, 2024 · 7 comments · Fixed by #8270
Closed

Support https://astral.sh/uv/install.sh running as Nobody #8242

VirtualTim opened this issue Oct 16, 2024 · 7 comments · Fixed by #8270
Labels
releases Related to building and distributing release artifacts of uv upstream An upstream dependency is involved

Comments

@VirtualTim
Copy link

VirtualTim commented Oct 16, 2024

I would like to use uv as a jenkins action, similar to https://github.com/astral-sh/setup-uv.
When I'm running inside a docker container, Jenkins runs as Nobody (specifically -u 1000:1000).
$HOME evaluates to /, which I do not have permission to write to.

It seems like I can get things working by running:

export CARGO_HOME=$WORKSPACE/cargo
export HOME=$CARGO_HOME/uv
curl -LsSf https://astral.sh/uv/install.sh | sh -s -- -v --no-modify-path
export UV_CACHE_DIR=$CARGO_HOME/.cache/uv

I have concerns about how future-proof this is. Is the file written to $HOME/.config/uv/uv-receipt.json important?
Is this likely to cause other things to break?
It would be nice if I could install this without having to temporarily modify $HOME.

@charliermarsh charliermarsh added upstream An upstream dependency is involved releases Related to building and distributing release artifacts of uv labels Oct 16, 2024
@charliermarsh
Copy link
Member

In the next release, you should be able to set UV_UNMANAGED_INSTALL to the exact location you want to use, without a receipt: https://opensource.axo.dev/cargo-dist/book/installers/usage.html#receipt. It seems like a good fit for your use-case.

@VirtualTim
Copy link
Author

Awesome. Thanks for the quick response, and for updating the documentation.

@VirtualTim
Copy link
Author

VirtualTim commented Oct 18, 2024

@charliermarsh I just tried out uv 0.4.23 and 0.4.24, and I still need to modify HOME.
Installing like this works fine:

export CARGO_HOME=$WORKSPACE/cargo
export UV_UNMANAGED_INSTALL=$CARGO_HOME/uv
export UV_CACHE_DIR=$CARGO_HOME/.cache/uv
curl -LsSf https://astral.sh/uv/install.sh | sh -s -- -v --no-modify-path

However when I attempt to setup a venv I get the following error:

uv venv --python 3.13
  x failed to create directory `/.local/share/uv/python`
  `-> Permission denied (os error 13)

same command with a modified $HOME:

export HOME=$(pwd)
uv venv --python 3.13
Using CPython 3.13.0
Creating virtual environment at: .venv

Should I create a separate issue?

@charliermarsh
Copy link
Member

@VirtualTim -- That looks a bit different. You may need to set UV_PYTHON_INSTALL_DIR if you want the python installs to go elsewhere (see: https://docs.astral.sh/uv/configuration/environment/).

@VirtualTim
Copy link
Author

VirtualTim commented Oct 21, 2024

I'm now running with:

export UV_UNMANAGED_INSTALL=$WORKSPACE/cargo
export UV_PYTHON_INSTALL_DIR=$UV_UNMANAGED_INSTALL/python
export UV_CACHE_DIR=$CARGO_HOME/.cache/uv
export uv=$UV_UNMANAGED_INSTALL/uv
curl -LsSf https://astral.sh/uv/install.sh | sh -s -- -v

$uv venv --python 3.13

This all seems to work as expected.
I would have expected UV_PYTHON_INSTALL_DIR to default to somewhere under UV_CACHE_DIR.

It might be a good idea to add the defaults to the documentation (I also see UV_UNMANAGED_INSTALL is missing).


On an unrelated note, I really appreciate this tool. My use-case is that I want to run tests against a cross-platform SDK. I have ~10 different platforms to test on. These tests are written in Python. Managing Python (and dependency) versions would normally be a huge headache, but now I can just run uv in my build scripts, and my environment is set up. Now updating python versions across VMs/docker images/OSs is as simple as just changing one number in a Jenkinsfile.

@VirtualTim
Copy link
Author

Also, if you'd like, I could add a quick guide here https://docs.astral.sh/uv/guides/ on how to run as Nobody?
The guide would basically just be a copy/paste of the snippet I commented above.

@zanieb
Copy link
Member

zanieb commented Oct 21, 2024

I don't think is a common enough use-case to cover in the top-level guides. I'd definitely appreciate some content on it though. If you put up a pull request with the content I can try to figure out where it fits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
releases Related to building and distributing release artifacts of uv upstream An upstream dependency is involved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants