Warn if --project directory does not exist#17714
Conversation
crates/uv/tests/it/run.rs
Outdated
|
|
||
| /// Using `--project` with a file path should warn (ignoring the eventual error). | ||
| #[test] | ||
| #[cfg(unix)] // TODO(konsti): Currently this doesn't error on Windows, but the result will vanish with the hard error |
There was a problem hiding this comment.
Currently, there's different behavior in this test on Unix and on Windows (I haven't investigated the Windows case, but this is bogus --project usage already). This difference will vanish when we upgrade the warning to an error, so I kept it as a TODO comment.
There was a problem hiding this comment.
I think it's important to know why this doesn't fail on Windows per #17714 (comment)
crates/uv/tests/it/run.rs
Outdated
|
|
||
| ----- stderr ----- | ||
| warning: Project path `not-a-directory` is not a directory. This will become an error in the future. | ||
| error: failed to open file `[TEMP_DIR]/not-a-directory/uv.toml`: Not a directory (os error 20) |
There was a problem hiding this comment.
Why do we attempt to open uv.toml there?
There was a problem hiding this comment.
I think we try to discover configuration in the project. TBH I don't don't see this error as a concern, but as additional motivation to now warn and eventually error with a proper message, instead of failing like this. As in, the test is surfacing something that's broken today, and this PR is part of solving this better. It's just that IMHO it isn't worth it to build an intermediate good solution here when we know that changing the warning to error is a good solution.
There was a problem hiding this comment.
But doesn't that mean this is already an error today? in which case, why are we bothering with a warning?
There was a problem hiding this comment.
Ah we fail because, as it says, it's "not a directory" so the system cannot traverse to attempt to read the child file. I think we should just fix the error message in this case on Linux and not warn?
There was a problem hiding this comment.
Good point, changed it to an error.
dbd4489 to
62571a2
Compare
72f2a14 to
75526f2
Compare
cc64262 to
641be9a
Compare
e838cf7 to
d088cb0
Compare
When `--project` points to a file (e.g., `pyproject.toml`), resolve to its parent directory with a deprecation warning instead of erroring. This restores the pre-0.10.10 behavior that was broken by astral-sh#17714. Closes astral-sh#18508 https://claude.ai/code/session_01NSUgyAxK5iz4VXKFW2L5ja
When `--project` points to a file (e.g., `pyproject.toml`), resolve to its parent directory with a deprecation warning instead of erroring. PR astral-sh#17714 added a hard error for this case on the assumption that it was "already broken on Linux", but it actually worked accidentally: `Workspace::discover` walks `.ancestors()` from the given path, so passing `--project project/pyproject.toml` would walk up one level and find the `pyproject.toml` in the parent directory — the correct project root. This restores the pre-0.10.10 behavior while adding a deprecation warning to guide users toward passing a directory instead. Closes astral-sh#18508 https://claude.ai/code/session_01NSUgyAxK5iz4VXKFW2L5ja
When `--project` points to a file, resolve to its parent directory. Passing `--project path/to/pyproject.toml` is explicitly allowed without warning. Other file types emit a deprecation warning. PR astral-sh#17714 added a hard error for file paths on the assumption that it "already errors on Linux", but it actually worked accidentally: `Workspace::discover` walks `.ancestors()` from the given path, so passing `--project project/pyproject.toml` would walk up one level and find the `pyproject.toml` in the parent directory — the correct project root. Closes astral-sh#18508 https://claude.ai/code/session_01NSUgyAxK5iz4VXKFW2L5ja
Use the same `Project path ... is not a directory` phrasing and `project_path.user_display()` as the original PR astral-sh#17714 code. https://claude.ai/code/session_01NSUgyAxK5iz4VXKFW2L5ja
…-sh#18508) Fix a regression from astral-sh#17714 where `--project pyproject.toml` stopped working. When `--project` points to a `pyproject.toml` file, resolve to its parent directory since downstream code expects a directory. For other file types, emit a warning (or error with preview flag) and let downstream code fail naturally if there is no ancestor project. https://claude.ai/code/session_01NSUgyAxK5iz4VXKFW2L5ja
…to a warning on other files (#18513) Closes #18508 This unintentionally regressed in #17714 as it appeared that `--project <file>` always failed but it actually succeeds if the file is has an ancestor directory with a `pyproject.toml`. This also removes the warning for `--project [path/]pyproject.toml` as I think that's a fine use-case. --------- Co-authored-by: Claude <noreply@anthropic.com>
For #17093
Errors if
--projectpoints to a file, as this already errors on Linux.