Avoid panic for non-UTF-8 virtualenv paths - #20375
Conversation
|
Why does a virtual environment path need to be utf-8? Just for the activation scripts? I am unsure that should error? |
|
We assume that our paths are UTF-8 serializable, so that we can use the location in UTF-8 files, which is why this code previously panicked; This isn't the first non-UTF-8 error variant we're adding. |
|
Probably too large of a change for just this PR, but maybe we can use camino for the subset of path operations that we want to enforce UTF-8 on? I think the APIs/error states it provides are pretty ergonomic. (OTOH, it's another dep.) |
uv test inventory changesThis PR changes the tests when compared with the latest
|
|
camino would be nice, but it would require changing almost all of the path handling we do. |
|
Regarding regression safety: This turns an existing panic in |
[#20375](#20375) added a non-UTF-8 virtualenv-path test that fails on macOS because APFS rejects the path during directory creation, before the activation-script validation is reached ([failing CI job](https://github.com/astral-sh/uv/actions/runs/29429195830/job/87399638975)). Validate the absolute destination before modifying the filesystem and assert that a rejected path does not leave a partially created environment.
A non-UTF-8
uv venvdestination currently panics while generating activation scripts. Return a clear error at the activation-script conversion site instead.