uv icon indicating copy to clipboard operation
uv copied to clipboard

Work across multiple drives

Open YDX-2147483647 opened this issue 1 year ago • 2 comments

$ 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-dir or UV_CACHE_DIR to set a different cache directory on file:///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?

YDX-2147483647 avatar Aug 25 '24 18:08 YDX-2147483647

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.

charliermarsh avatar Aug 25 '24 20:08 charliermarsh

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.

samypr100 avatar Aug 25 '24 22:08 samypr100

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.

Holi0317 avatar Sep 02 '24 15:09 Holi0317

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?

Winand avatar Jan 01 '25 23:01 Winand

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?

This worked for me, thanks.

maphew avatar Mar 03 '25 17:03 maphew

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.

Winand avatar Mar 06 '25 20:03 Winand

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..

wilsonmfaria avatar May 23 '25 12:05 wilsonmfaria

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.

mirh avatar May 23 '25 21:05 mirh

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 ...

maphew avatar May 24 '25 06:05 maphew