Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explain how to handle ambiguous local environments #17048

Merged
merged 3 commits into from
Sep 29, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/python/pants/core/util_rules/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ async def determine_local_environment(
result_name, _tgt = compatible_name_and_targets[0]
return ChosenLocalEnvironmentName(result_name)

# TODO(#7735): Maybe allow the user to disambiguate what __local__ means via an option?
raise AmbiguousEnvironmentError(
softwrap(
f"""
Expand All @@ -426,7 +425,25 @@ async def determine_local_environment(

To fix, either adjust the `{CompatiblePlatformsField.alias}` field from those
targets so that only one includes the value `{platform.value}`, or change
`[environments-preview].names` so that it does not define some of those targets.
`[environments-preview].names` so that it does not define some of those targets. It is
often useful to still keep the same `local_environment` target definitions in BUILD
Eric-Arellano marked this conversation as resolved.
Show resolved Hide resolved
files; instead, do not give a name to each of them in `[environments-preview].names` to
avoid ambiguity. Then, you can override which target a particular name points to by
overriding `[environments-preview].names`. For example, you could set this in
`pants.toml`:

[environments-preview.names]
linux = "//:linux_env"
macos = "//:macos_local_env"

Then, for CI, override what the name `macos` points to by setting this in
`pants.ci.toml`:

[environments-preview.names.add]
macos = "//:macos_ci_env"

Locally, you can override `[environments-preview].names` like this by using a
`.pants.rc` file, for example.
"""
)
)
Expand Down