Use fs_err for cachedir errors (#3304)

When running

```
set UV_CACHE_DIR=%LOCALAPPDATA%\uv\cache-foo && uv venv venv
```

in windows CMD, the error would be just

```
error: The system cannot find the path specified. (os error 3)
```

The problem is that the first action in the cache dir is adding the tag,
and the `cachedir` crate is using `std::fs` instead of `fs_err`. I've
copied the two functions we use from the crate and changed the import
from `std::fs` to `fs_err`.

The new error is

```
error: failed to open file `C:\Users\Konstantin\AppData\Local\uv\cache-foo \CACHEDIR.TAG`
  Caused by: The system cannot find the path specified. (os error 3)
```

which correctly explains the problem.

Closes #3280
This commit is contained in:
konsti 2024-04-29 16:33:10 +02:00 committed by GitHub
parent 22d8619c37
commit 1344cfae4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 78 additions and 7 deletions

View file

@ -20,7 +20,6 @@ pypi-types = { workspace = true }
uv-fs = { workspace = true, features = ["tokio"] }
uv-normalize = { workspace = true }
cachedir = { workspace = true }
clap = { workspace = true, features = ["derive", "env"], optional = true }
directories = { workspace = true }
fs-err = { workspace = true, features = ["tokio"] }

View file

@ -13,7 +13,7 @@ use tracing::debug;
use distribution_types::InstalledDist;
use pypi_types::Metadata23;
use uv_fs::directories;
use uv_fs::{cachedir, directories};
use uv_normalize::PackageName;
pub use crate::by_timestamp::CachedByTimestamp;