aspect-build / aspect-build/rules_py

py_binary direct execution loses declared runtime environment after native launcher migration

Open
#1,360 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
145
Forks
97
Avg merge
1d 1h
Merged PRs (30d)
71

Description

rules_py 2's native py_binary launcher passes argv and runfiles to hermetic-launcher but returns the merged venv/binary environment only through RunEnvironmentInfo. A built launcher invoked directly by another executable therefore loses its declared environment.

A concrete reproduction is NLTK_DATA: a corpus is in runfiles and the inner binary declares its location, but a local wrapper execs the binary directly and startup cannot find the corpus. A consumer-side launcher override works around this narrowly.

#993 contained the corresponding direct-execution regression and attempted to bake env through a shell launcher; that approach was correctly rejected over shell interpolation. #464 intentionally preserved Bazel/rules_python semantics that env must not leak into action tools. I do not think the existing env or env_inherit behavior should change silently.

Would an explicit opt-in launcher_env/direct_env contract be acceptable? It would need to:

- preserve literal values without shell evaluation (including quotes, backticks, dollars, and backslashes);
- distinguish runfiles-backed paths and resolve them at launch, including manifest-only runfiles;
- preserve venv/binary override ordering and contextual variables;
- never serialize inherited values or secrets;
- leave ordinary env/env_inherit and action-tool behavior unchanged.

A falsifying regression would declare a literal plus an rlocationpath data target on a py_binary, resolve and exec that binary from a sh_test after unsetting both keys, and assert the literal is unchanged and the data path exists. The previous shell-injection discussion is https://github.com/aspect-build/rules_py/pull/993#discussion_r3212471823 and the native-launcher context is https://github.com/aspect-build/rules_py/pull/1045#discussion_r3365574102.

— tamirdex

Contributor guide

Open the contributing guide

Research direction

Start by reading the py_binary native launcher path and hermetic-launcher integration, then inspect the sh_test reproduction described in the issue. Define and validate an explicit direct-execution contract that preserves literal values and resolves rlocationpath data, while leaving env, env_inherit, and action-tool behavior unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.