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(bootstrap) handle when the runfiles env vars are not correct (#3644)
This change addresses an issue that has existed since 1.7.0 where Python
binaries launched as subprocesses could incorrectly inherit and use
runfiles environment variables (`RUNFILES_DIR`,
`RUNFILES_MANIFEST_FILE`) from the parent process.
## Why this change is needed:
When a Python binary spawns another Python binary, the child process
inherits the environment variables. If the parent had runfiles-related
environment variables set, the child would attempt to use the parent's
runfiles tree, which is incorrect and leads to import errors if the
child has different dependencies or a different runfiles layout.
## Behavior Before:
A child Python process would trust and use any existing `RUNFILES_DIR`
and `RUNFILES_MANIFEST_FILE` environment variables. If these were set by
a parent Python process, they would point to the parent's runfiles,
causing the child to fail when trying to load its own resources or
dependencies.
## Behavior After:
The Python bootstrap scripts now include a check to validate the
inherited runfiles environment variables. If the runfiles variables
exist but do not point to the correct location for the current binary,
the bootstrap script will unset both `RUNFILES_DIR` and
`RUNFILES_MANIFEST_FILE` from the environment. This allows the
subsequent fallback logic in the bootstrap process to correctly locate
the runfiles for the current process, ensuring dependencies are resolved
properly. This modification has been applied to both bootstrap template
files.
This change ensures that even nested Python binary calls correctly find
their respective runfiles.
Fixes#3518
---------
Co-authored-by: Ignas Anikevicius <240938+aignas@users.noreply.github.com>
0 commit comments