quaint-piano-62770
06/08/2024, 8:25 PM--test-extra-env-var, which seems completely unrelated
% pants --no-pantsd package src/my-project:docker-base-image
01:51:15.56 [ERROR] 1 Exception encountered:
Engine traceback:
in `package` goal
ValueError: An invalid variable was requested via the --test-extra-env-var mechanism: {PIP_EXTRA_INDEX_URL:
Relevant sections from the pants.toml file:
[docker]
build_verbose = "True"
env_vars = [
"HOME",
"DOCKER_CONFIG=%(homedir)s/.docker",
"DOCKER_CONTEXT=default",
"NEXUS_USER",
"NEXUS_PWD",
]
tools = ["docker-credential-ecr-login", "sh"]
[docker.registries.my-company-aws]
address = "<AWS ECR URL>"
[docker.build_args]
PIP_EXTRA_INDEX_URL = "<INTERNAL NEXUS REPO URL>"broad-processor-92400
06/09/2024, 3:53 AM[test] subsection? And/or are there any other search results for PIP_EXTRA_INDEX_URL in your configuration/repository?quaint-piano-62770
06/09/2024, 5:13 AMtest subsections in pants.toml looks like this
[test]
output = "all"
use_coverage = true
[coverage-py]
report = ["console", "xml", "html"]
and PIP_EXTRA_INDEX_URL appears in my project’s BUILD file as
docker_image(
name="docker-base-image",
repository="my-project-base",
source="docker/base/Dockerfile",
context_root="./",
dependencies=[
":files",
],
extra_build_args=["PIP_EXTRA_INDEX_URL"],
registries=[
"@my-company-aws",
],
image_tags=["latest"],
)
and in the Dockerfile as
...
ARG PIP_EXTRA_INDEX_URL
...broad-processor-92400
06/09/2024, 5:49 AMquaint-piano-62770
06/09/2024, 6:06 AMbroad-processor-92400
06/10/2024, 1:10 AMNEXUS_USER=a NEXUS_PWD=b pants package src/my-project:docker-base-image.
If you have time, reducing it even further would be useful, to remove everything except what is required to reproduce the problem (e.g. it seems like a bunch of the env var configuration in pants.toml could be removed or simplified).
Also, it'd be good to try it with the latest versions of pants (2.21.0 is the latest stable, and 2.22.0a0 is the latest dev release): maybe they have fixed the problem or improved the error message!quaint-piano-62770
06/10/2024, 5:25 AMbroad-processor-92400
06/10/2024, 5:27 AMquaint-piano-62770
06/10/2024, 5:28 AMquaint-piano-62770
06/10/2024, 5:52 AM% pants package src/my-project:docker-base-image
11:18:55.26 [ERROR] Expected build_args to contain an 'add' element, a 'remove' element or both but found: {"PIP_EXTRA_INDEX_URL": String("<SOME_URL_HERE>")}
Use --print-stacktrace for more error details and/or -ldebug for more logs.
See <https://www.pantsbuild.org/2.22/docs/using-pants/troubleshooting-common-issues> for common issues.
Consider reaching out for help: <https://www.pantsbuild.org/community/getting-help>broad-processor-92400
06/10/2024, 6:00 AM[docker].build_args expects a list, not key/value pairs. https://www.pantsbuild.org/2.21/reference/subsystems/docker#build_args
So, the error message was very bad, and is now merely just quite bad.
Does this work?
[docker]
...
build_args = ["PIP_EXTRA_INDEX_URL=<SOME_URL_HERE>"]quaint-piano-62770
06/10/2024, 6:04 AMquaint-piano-62770
06/10/2024, 11:19 AMbroad-processor-92400
06/10/2024, 11:29 AMquaint-piano-62770
06/12/2024, 11:31 AMbroad-processor-92400
06/12/2024, 7:44 PM