astral-sh / uv

An extremely fast Python package and project manager, written in Rust.
https://docs.astral.sh/uv
Apache License 2.0
23.18k stars 668 forks source link

installer: confusing UV_INSTALL_DIR behavior #8300

Open ilyagr opened 7 hours ago

ilyagr commented 7 hours ago

I ran

curl -LsSf https://astral.sh/uv/install.sh | \
  env INSTALLER_NO_MODIFY_PATH=1 UV_INSTALL_DIR=~/.local/bin sh

The result included the message "installing to ~/.local/bin/bin":

$ curl -LsSf https://astral.sh/uv/install.sh | env INSTALLER_NO_MODIFY_PATH=1 UV_INSTALL_DIR=~/.local/bin sh
downloading uv 0.4.23 aarch64-apple-darwin
installing to ~/.local/bin/bin
  uv
  uvx
everything's installed!

~Actually, the install seemed to correctly go to ~/.local/bin, it's just the message that's wrong.~

Actually, the install ended up going in /Users/ilyagr/tmp/~/.local/bin/bin/uv (with a literal ~ in the name), which has several problems with it. I was in /Users/ilyagr/tmp/ when running the command.

Workaround:

The correct command would have been:

curl -LsSf https://astral.sh/uv/install.sh | \
   env INSTALLER_NO_MODIFY_PATH=1 UV_INSTALL_DIR=/Users/ilyagr/.local sh

without the /bin in /Users/ilyagr/.local.

Suggestions

It would have helped if the "installing..." message printed the absolute path.

Now that the variable is called UV_INSTALL_DIR instead of CARGO_HOME, it makes less sense that /bin is added to it. I'm not sure what to do about it.

Absent a better fix, the docs should perhaps be updated to explain this, somehow, e.g. by including the working command. I am not sure what's going wrong with the ~ expansion for me.

Another minor issue: curl -LsSf https://astral.sh/uv/install.sh | sh -s -- --help still talks about CARGO_HOME. This might be OK if it still works.

ilyagr commented 6 hours ago

On my system (Mac + fish), there is a helpful printenv command that shows:

$ a=~ printenv a
/Users/ilyagr
$ env a=~ printenv a
~

This makes no sense to me. I filed a question at https://github.com/fish-shell/fish-shell/issues/10794 about that.

zanieb commented 6 hours ago

Actually, the install ended up going in /Users/ilyagr/tmp/~/.local/bin/bin/uv (with a literal ~ in the name), which has several problems with it. I was in /Users/ilyagr/tmp/ when running the command.

Yeah this seems like a shell issue, that's weird. I'm confused too honestly.

Sounds like you want UV_UNMANAGED_INSTALL if you don't want to create the bin directory? it's setup this way because we might need to install other things than binaries.

ilyagr commented 6 hours ago

Bash acts the way I'd expect, so I thought it was a fish issue. However, zsh and dash both act like fish, so I guess the env trick I suggested a while ago is just not great. Sorry.

zanieb commented 6 hours ago

The documentation only recommends an absolute path though, right?