Skip to content

~ Tildes in environment variables not expanded before use #9326

@fynnsu

Description

@fynnsu
export UV_CACHE_DIR="~/uv_cache"
# Use uv
uv venv
uv pip install numpy

Will produce a subfolder '~' with 'uv_cache' in it instead of expanding to /home/user/uv_cache when used.

Note: Since shells will often expand the tildes themselves this may not often be a problem. In the above example, using export UV_CACHE_DIR=~/uv_cache (without the ""), works as my shell expands the ~ before setting the env variable.

I ran into this issue because I was trying to use astral-sh/setup-uv with cache-local-path: ~/.uv_cache which then is used to set UV_CACHE_DIR. Unfortunately here, whether I include the "" or not, the env variable gets set with the ~ giving me the wrong cache dir.

I think it would be useful to support ~ at the start of paths for UV_CACHE_DIR and other similar path environment variables (untested but I'm guessing they have the same limitation).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions