uv: Installation of uv fails when $HOME variable is not set

When I Tried running the following command (mentioned in the docs) to install uv in amazon linux box where $HOME directory is unset for reasons unknown i get a failure saying $HOME is unset

curl -LsSf https://astral.sh/uv/install.sh | sh

Example - https://github.com/kishaningithub/setup-python-amazon-linux/issues/14#issuecomment-2325627058

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 18 (7 by maintainers)

Commits related to this issue

Most upvoted comments

hey folks! I work on cargo-dist which is what the astral team uses to distribute uv, really appreciate the discussion on this article and i’ve opened up an issue on our tracker to fully gather requirements for the install mode ya’ll are discussing here.

https://github.com/axodotdev/cargo-dist/issues/1400

would love for you to share ideas there (i’ll also continue monitoring this issue for ideas!)

You can now set UV_UNMANAGED_INSTALL to define a standalone installation directory, e.g.:

export UV_UNMANAGED_INSTALL=/foo/bar
curl -LsSf https://astral.sh/uv/install.sh | sh -s -- -v --no-modify-path

@charliermarsh with UV_UNMANAGED_INSTALL you won’t need to pass --no-modify-path as that’s behavior rolled into the env var

Just noticed that this incantation works to install version 0.4.7 of uv and uvx to /usr/bin without writing any env files.

curl -LsSf https://astral.sh/uv/0.4.7/install.sh | UV_INSTALL_DIR=/usr sh

Setting UV_INSTALL_DIR=/ so it writes to /bin sort of works, but it appends a slash, so it becomes //bin which is not in $PATH, which makes the installer write /env and /env.fish as well.

@charliermarsh Just to confirm, this is still an issue - I’ve applied the fix @mil-ad suggested to get this working, but yeah, on Amazon Linux 2023 (or another OS where $HOME isn’t set), the installer cannot run, even in UV_UNMANAGED_INSTALL set. Latest version.

Same, I just defined a dummy HOME="foobar" along with UV_UNMANAGED_INSTALL and it runs fine. The only problem is that one line.

@charliermarsh The issue is not yet resolved. Getting the following error.

> curl -LsSf https://astral.sh/uv/install.sh | sh

sh: line 53: HOME: unbound variable

This is present in the latest install script. The failing code line is RECEIPT_HOME="${HOME}/.config/uv" which is unconditionally trying to resolve $HOME always.

I ran into this as well, and ended up defining a HOME env var. My use case is auto installing uv in a specific folder, using CARGO_DIST_FORCE_INSTALL_DIR, and HOME in my case ideally shouldn’t be involved at all. I see it’s used to generate a receipt file (which is also not needed in this case).

What would be nice for automations like this is if the installer script simply dropped the correct uv binary in the specified target folder, and that’s it (no PATH modifications, no HOME involved etc)

I think it would be great if we can pass in an argument to the shell script to explicitly state in which directory the installation should happen. That way the $HOME dependency can disappear.