mysterious-advantage-81972
03/11/2026, 4:58 PM[python-repos].indexes busts cache keys for Docker PEX builds 🧵mysterious-advantage-81972
03/11/2026, 4:58 PM[subprocess-environment].env_vars. However, we're stuck on pants package (PEX builds inside docker_environment).
Setup:
Pants 2.31.0
• CodeArtifact as our PyPI index, configured via [python-repos].indexes with token interpolation:
indexes = ["<https://aws>:%(env.CODEARTIFACT_AUTH_TOKEN)<mailto:s@our-domain.d.codeartifact.us-east-1.amazonaws.com|s@our-domain.d.codeartifact.us-east-1.amazonaws.com>/pypi/repo/simple/"]
Depot Cache (<grpcs://cache.depot.dev>) as REAPI remote cache
• PEX binaries built in a docker_environment (for cross-platform Linux builds)
The problem: The CodeArtifact token rotates every run (STS-based, max 12h lifetime). Since the resolved index URL (with embedded token) becomes part of PEX resolver process args, every token rotation changes the cache key for PEX resolution processes. This cascades -- different PEX output means different Docker build inputs, so docker build processes also miss cache.
What we tried:
.netrc approach (token outside Pants fingerprint): Works for local processes (lint/check/test) but not inside docker_environment -- the host .netrc file isn't accessible in Docker.
• Writing .netrc into the Docker named-cache volume: The run goal doesn't execute in Docker environments ("The run goal only runs in the local environment"), so we can't trigger volume creation before needing it.
• docker_environment mounts field: PR #20322 was closed without merging.
• subprocess_environment_env_vars override on `docker_environment`: Can pass env vars but can't get the .netrc file into the container.
Current workaround: We're considering a scheduled workflow that refreshes the CodeArtifact token every 10 hours and stores it as a stable GitHub secret, so all CI runs within that window share the same token. This works but means ~2 cache busts per day.
Question: Is there a better way to authenticate to a private PyPI index from inside a docker_environment without the credentials ending up in process cache keys? Are there plans to revisit the mounts feature (PR #20322) or support credential helpers / keyring for docker_environment processes?happy-kitchen-89482
03/11/2026, 8:09 PMhappy-kitchen-89482
03/11/2026, 8:13 PMhappy-kitchen-89482
03/11/2026, 9:26 PMmysterious-advantage-81972
03/11/2026, 10:52 PMCODEARTIFACT_AUTH_TOKEN to Docker PEX processes without it busting cache keys. No need for the stable token workaround, no scheduled refresh workflow, no .netrc tricks.
That's essentially what the linked PR proposed ("reified environment variables") -- env vars whose actual values are applied after cache lookup, not before.some-insurance-58590
03/18/2026, 5:41 PMallowing listing env vars that are available to the process but are not part of its cache key? This could potentially have other usesThis would be nice to have! Another use case from my job: We have some integration tests run via Pants that need access to GCP. In CI, we use google-github-actions/gcp-auth which stores the credentials (and sets
GOOGLE_APPLICATION_CREDENTIALS) at a unique path for each run (maybe timestamp based?). This kept busting our cache.
It was easy enough to work around (just move the file to a constant path like /tmp/google_creds.json & overwrite the env var). But it would be nice to have a built-in option to ignore certain env vars for cache lookupsmysterious-advantage-81972
03/19/2026, 6:16 PM- name: Install OpenTofu
uses: opentofu/setup-opentofu@fc711fa910b93cba0f3fbecaafc9f42fd0c411cb
with:
tofu_version: 1.10.8mysterious-advantage-81972
03/19/2026, 6:16 PMsetup-opentofu GitHub Action modifies PATH before Pants runs
We isolated the issue through binary search of our CI workflow steps. The opentofu/setup-opentofu action was the sole culprit.
The mechanism: setup-opentofu calls addPath(pathToCLI) which prepends the OpenTofu binary directory to PATH via GITHUB_PATH. This modified PATH is inherited by pantsd when it starts, and Pants includes PATH in process cache key computation. Since the path includes runner-specific or temp-specific components, it differs between CI runs, busting every test cache key.
The fix: Move setup-opentofu to after all Pants goals in the workflow. OpenTofu is only needed for infrastructure plan/apply steps which run after lint/check/test/package.
Why lint/check/package weren't affected: We believe those goals have fewer processes whose cache keys include PATH, or their process construction resolves PATH differently. This could use further investigationmysterious-advantage-81972
03/19/2026, 6:18 PMhappy-kitchen-89482
03/19/2026, 7:46 PMCODEARTIFACT_AUTH_TOKEN issue you mentioned above?happy-kitchen-89482
03/19/2026, 7:46 PMmysterious-advantage-81972
03/19/2026, 10:27 PMCODEARTIFACT_AUTH_TOKEN it's certainly a bit hacky but basically just mint the token for 12h so it only busts the cache on expiry. Definitely far from a perfect solution. Here's the code snippet if it's helpful for anyone.mysterious-advantage-81972
03/19/2026, 10:29 PMIt was easy enough to work around (just move the file to a constant path like& overwrite the env var). But it would be nice to have a built-in option to ignore certain env vars for cache lookups/tmp/google_creds.json
mysterious-advantage-81972
03/19/2026, 10:29 PMhappy-kitchen-89482
03/20/2026, 12:24 AMmysterious-advantage-81972
03/20/2026, 4:50 PMCODE_ARTIFACT_TOKEN changed every build and busted the cache. This one we 🩹 with just only refreshing the token every ~11-12 hours.
2. The second issue was specifically the cache being busted on pants test specifically in CI as a result of the open_tofu binary being installed on a different tmp path each time. I still don't understand why this affected the test cache only or why it affected it at all 🤔mysterious-advantage-81972
03/20/2026, 4:50 PMhappy-kitchen-89482
03/20/2026, 8:10 PM