Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

normalize_path breaks relative python interpreters #3012

Closed
konstin opened this issue Apr 12, 2024 · 2 comments · Fixed by #3013
Closed

normalize_path breaks relative python interpreters #3012

konstin opened this issue Apr 12, 2024 · 2 comments · Fixed by #3013
Assignees
Labels
bug Something isn't working

Comments

@konstin
Copy link
Member

konstin commented Apr 12, 2024

-p/--python with relative paths is broken due to using normalize_path, which changes the path rather than just normalizing it.

$ cargo run -q -- venv -p ../cpython/python .venv3.13 -vv
 uv_interpreter::find_python::find_requested_python request=../cpython/python
      0.000439s   0ms DEBUG uv_interpreter::find_python Starting interpreter discovery for Python @ `../cpython/python`
[crates/uv-interpreter/src/find_python.rs:55:46] request = "../cpython/python"
[crates/uv-interpreter/src/find_python.rs:55:26] normalize_path(dbg!(request)) = "cpython/python"
  × failed to canonicalize path `cpython/python`
  ╰─▶ No such file or directory (os error 2)
@konstin konstin added the bug Something isn't working label Apr 12, 2024
@charliermarsh charliermarsh self-assigned this Apr 12, 2024
@charliermarsh
Copy link
Member

I suppose I can take this.

@charliermarsh
Copy link
Member

It looks like normalize_path assumes the argument path is absolute. I'll fix and document.

charliermarsh added a commit that referenced this issue Apr 12, 2024
… the current directory (#3013)

## Summary

It turns out that `normalize_path` (sourced from Cargo) has a subtle
bug. If you pass it a relative path that traverses beyond the root, it
silently drops components. So, e.g., passing `../foo/bar`, it will just
drop the leading `..` and return `foo/bar`.

This PR encodes that behavior as a `Result` and avoids using it in such
cases.

Closes #3012.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants