uv
uv copied to clipboard
Work across multiple drives
$ uv add <any-package>
warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance.
If the cache and target directories are on different filesystems, hardlinking may not be supported.
If uv only has cache in C:\, then I am unable to use uv in D:\, at least with “degraded performance”. This case might be common for Windows machines. For example, https://github.com/astral-sh/uv/issues/6397#issuecomment-2303368424:
this is about the relationship between the cache directory and the drive you're installing on. I'm guessing your cache is not on
file:///E:? You can use--cache-dirorUV_CACHE_DIRto set a different cache directory onfile:///E:.
I understand that hard links are not permitted across drives. However, pnpm creates multiple stores (one per drive), solving the issue. Will it be possible for uv?
I suppose we could do something like that. It could end up being less efficient sometimes, though, since you duplicate and re-cache any data that's used across drives.
This arguably applies on linux too as you can have a mounted secondary drive under some arbitrary path as stated here https://github.com/pnpm/pnpm/issues/712#issuecomment-363295013, I do think using UV_CACHE_DIR is a reasonable solution in the mean time.
Also on MacOS as well. I use a separate, case sensitive filesystem for all code project that is different form the fs backing ~/.cache.
While this is not mentioned in the pnpm thread, I think users who hits this issue are storing all of their projects in a separate filesystem. Whether it is because of disk space, speed or want to use a different fs. The current behavior is actually less efficient for us because the setup basically disables hard-link dependency deduplication.
So I can simply create uv.toml in the root folder of a disk with contents cache-dir = "D:/.uv/cache"? Do i understand it correctly that uv searches for uv.toml in all parent folders of a project?
Configuration files Specifically, uv will search for a pyproject.toml or uv.toml file in the current directory, or in the nearest parent directory.
It means that uv checks each parent folder until it finds the nearest uv.toml file?
So I can simply create
uv.tomlin the root folder of a disk with contentscache-dir = "D:/.uv/cache"? Do i understand it correctly that uv searches foruv.tomlin all parent folders of a project?
This worked for me, thanks.
This worked for me, thanks.
But it won't work if you put uv.tool section in pyproject.toml, because uv doesn't merge these configuration sources and use pyproject.toml OR the nearest uv.toml file.
On Windows, by using Powershell, I 've added this to my profile... So once I open a terminal, it sets the UV_CACHE_DIR based on the drive... Except for C: which is the standard..
$DriveLetter = (Get-Location).Drive.Name
if ($DriveLetter -in @("D", "E")) {
switch ($DriveLetter) {
"D" { $Env:UV_CACHE_DIR = "D:\.uv" }
"E" { $Env:UV_CACHE_DIR = "E:\.uv" }
}
Write-Host "UV Cache set to: UV_CACHE_DIR=$Env:UV_CACHE_DIR"
}
It works quite well..
Can't you make something up with junction points? You can only soft link individual folders but that shouldn't be a problem with the layout archive-v0 already has.
TIL: On Windows setting the cache without drive letter will make it use the current drive of wherever the project is.
setx UV_CACHE_DIR "\.uv"
:: will use C:\.uv
C:\Users\me\projects> uv run ...
:: will use E:\.uv
E:\work\projects> uv run ...