Skip to content

Conversation

@chrisnovakovic
Copy link
Contributor

@chrisnovakovic chrisnovakovic commented Oct 29, 2025

It would be useful for executables to be able to tell whether they are running within a Please build environment, whether or not that environment is sandboxed. One definitive use case is when deciding whether or not resources should be loaded from $TMP_DIR, which has a special (and well-defined) meaning within a Please build environment but not outside of one, even though the variable may still be defined in the environment. The java-rules and python-rules plugins would both benefit from this, given that java_binary JARs and python_binary pexes have runtimes that are expected to be discovered dynamically but will be located at different paths depending on whether they are executing under plz test (inside a build environment) or plz run (outside a build environment).

Define the PLZ_ENV variable in Please build environments. This of course does not guarantee that the environment was created by Please, but is a better indicator of that than heuristics such as testing for the presence of other variables that happen to be defined in certain build environments, such as BUILD_CONFIG and _TEST_ID.

It would be useful for executables to be able to tell whether they are
running within a Please build environment, whether or not that
environment is sandboxed. One definitive use case is when deciding
whether or not resources should be loaded from `$TMP_DIR`, which has a
special (and well-defined) meaning within a Please build environment but
not outside of one, even though the variable may still be defined in the
environment. The java-rules and python-rules plugins would both benefit
from this, given that `java_binary` JARs and `python_binary` pexes have
runtimes that are expected to be discovered dynamically at run time but
will be located at different paths depending on whether they are
executing inside a build environment.

Define the `PLZ_ENV` variable in Please build environments. This of
course does not guarantee that the environment was created by Please,
but is a better indicator of that than heuristics such as testing for
the presence of other variables that happen to be defined in certain
build environments, such as `BUILD_CONFIG` and `_TEST_ID`.
@chrisnovakovic chrisnovakovic merged commit 4fec6ab into thought-machine:master Oct 29, 2025
13 checks passed
@chrisnovakovic chrisnovakovic deleted the plz_env-var branch October 29, 2025 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants