You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(venv): Don't use dirs as the interpreter (#665)
Fixes#664
On Linux and MacOS, the `current_exe()` path has likely been realpath-ed
by the system or the libc somewhere along the line. This means that if
the user types `.venv/bin/python3`, the entire symlink chain that may
point into will be chased and we'll get a path somewhere inside the
Bazel `execroot/` output tree. Critically on Linux this symlink tree
goes past the `.runfiles/` directory entry the user intended to create a
symlink to, which prevents our interpreter shim from delegating to a
`.runfiles/` packaged Python like the user desired.
In order for us to resolve "just enough" symlinks to identify the
`.runfiles/` tree, we need to manually resolve the path of the current
executable. Previously doing so would create a false positive if there
was a `./python` or `./python3` directory, and the interpreter shim was
invoked as `python3` which is ambiguous as to whether the user meant
`./python3` or `python3 from the $PATH`.
The fix here centers on two insights:
- The "real" interpreter can never be a directory (directly fixes the
bug)
- The "real" interpreter's absolute path _must_ have the _same_ absolute
path as whatever `current_exe()` is
### Changes are visible to end-users: yes
- Searched for relevant documentation and updated as needed: yes
- Breaking change (forces users to change their own code or config): no
- Suggested release notes appear below: yes
Fixed a bug which would cause the interpreter shims to identify
`./python3/` or `./python/` (directories) as the real path of the
interpreter "python3" rather than falling back to `which()` behavior.
### Test plan
- Manual testing
0 commit comments