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
Identified in manual testing of v1.6.0-rc0.
Because of overly conservative removals of `realpath` in #579, an issue
is exposed where `$VIRTUAL_ENV` would be an un-resolved relative path
both under Bazel and more significantly once a user activates a linked
venv. This isn't so bad for binaries which usually don't `chdir`, but
it's a problem for shells.
Since MacOS doesn't ship a `realpath` which can be configured to ignore
symlinks, we can't just `realpath` the runfiles dir or the virtualenv
home. But once we've configured a Python interpreter what we can do is
use `os.path.abspath`. Unlike `realpath`, `abspath` does not attempt to
resolve symlink path segments. It just uses `normpath` to eliminate
relative path segments. This allows us to compute an absolute path in a
portable way, once we get an appropriate interpreter up and running.
---
### Changes are visible to end-users: no
### Test plan
- Manual testing; please provide instructions so we can reproduce:
```
❯ bazel run //examples/py_binary:py_binary.venv
INFO: Analyzed target //examples/py_binary:py_binary.venv (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //examples/py_binary:py_binary.venv up-to-date:
bazel-bin/examples/py_binary/py_binary.venv
INFO: Elapsed time: 0.785s, Critical Path: 0.02s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/examples/py_binary/py_binary.venv
Linking: /private/var/tmp/_bazel_arrdem/93bfea6cdc1153cc29a75400cd38823a/execroot/aspect_rules_py/bazel-out/darwin_arm64-fastbuild/bin/examples/py_binary/.py_binary.venv -> /Users/arrdem/Documents/work/aspect/rules_py/examples/py_binary/.py_binary.venv
To activate the virtualenv run:
source /Users/arrdem/Documents/work/aspect/rules_py/examples/py_binary/.py_binary.venv/bin/activate
Link is up to date!
❯ source /Users/arrdem/Documents/work/aspect/rules_py/examples/py_binary/.py_binary.venv/bin/activate
❯ env | grep -e PYTHON -e RUNFILES -e VIRTUAL -e VENV | sort
PYTHONEXECUTABLE=/Users/arrdem/Documents/work/aspect/rules_py/examples/py_binary/.py_binary.venv/bin/python
PYTHONHOME=/private/var/tmp/_bazel_arrdem/93bfea6cdc1153cc29a75400cd38823a/execroot/aspect_rules_py/bazel-out/darwin_arm64-fastbuild/bin/examples/py_binary/py_binary.venv.runfiles/python_toolchain_aarch64-apple-darwin
RUNFILES_DIR=/private/var/tmp/_bazel_arrdem/93bfea6cdc1153cc29a75400cd38823a/execroot/aspect_rules_py/bazel-out/darwin_arm64-fastbuild/bin/examples/py_binary/py_binary.venv.runfiles
RUNFILES_MANIFEST_FILE=/private/var/tmp/_bazel_arrdem/93bfea6cdc1153cc29a75400cd38823a/execroot/aspect_rules_py/bazel-out/darwin_arm64-fastbuild/bin/examples/py_binary/py_binary.venv.runfiles/MANIFEST
RUNFILES_REPO_MAPPING=/private/var/tmp/_bazel_arrdem/93bfea6cdc1153cc29a75400cd38823a/execroot/aspect_rules_py/bazel-out/darwin_arm64-fastbuild/bin/examples/py_binary/py_binary.venv.runfiles/_repo_mapping
VIRTUAL_ENV_DISABLE_PROMPT=1
VIRTUAL_ENV=/Users/arrdem/Documents/work/aspect/rules_py/examples/py_binary/.py_binary.venv
```
0 commit comments