cool-easter-32542
04/19/2023, 12:38 AMdocker_image targets which were working fine for some time. Today I when to run one and encountered this error:
Failed to fire hook: while creating logrus local file hook: user: Current requires cgo or $USER, $HOME set in environment
[2023-04-18T20:58:17.637886000Z][docker-credential-desktop][F] get system info: exec: "sw_vers": executable file not found in $PATH
[goroutine 1 [running, locked to thread]:
[common/pkg/system.init.0()
[ common/pkg/system/os_info.go:32 +0x1bc
#3 ERROR: rpc error: code = Unknown desc = error getting credentials - err: exit status 1, out: ``
#5 [auth] sharing credentials for <http://123456789.dkr.ecr.us-east-1.amazonaws.com|123456789.dkr.ecr.us-east-1.amazonaws.com>
#5 sha256:00484c1754ca42cdfd60e0asdf234asdf8a41a33b1f30d70412c4254
#5 ERROR: error getting credentials - err: exit status 1, out: ``
------
> [internal] load metadata for <http://123456789.dkr.ecr.us-east-1.amazonaws.com/databricks-base:0.0.2|123456789.dkr.ecr.us-east-1.amazonaws.com/databricks-base:0.0.2>:
------
------
> [auth] sharing credentials for <http://123456789.dkr.ecr.us-east-1.amazonaws.com|123456789.dkr.ecr.us-east-1.amazonaws.com>:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: rpc error: code = Unknown desc = error getting credentials - err: exit status 1, out: ``
I've encountered this error before when I was first setting up pants in the repo and fixed it by adding the USER, HOME, and PATH variables to [docker.env_vars] in my pants.toml file. But now those variables are set (and appeared to be working for some time), leaving me with an unclear path to exposing these variables to the pants environment. I've also confirmed that sw_vers is in my PATH, and that USER and HOME are actually set.
# pants.toml
[docker]
env_vars = [
"HOME",
"USER",
"PATH",
"GIT_COMMIT"
]
With pants package -ldebug <target> I noticed this message in the logs:
spawned local process as Some(88403) for Process { argv: ["/usr/local/bin/docker", "build", "--pull=False", "--tag", "<http://12345667.dkr.ecr.us-east-1.amazonaws.com/test_image:latest|12345667.dkr.ecr.us-east-1.amazonaws.com/test_image:latest>", "--file", "src/docker/another/Dockerfile", "."], env: {"__UPSTREAM_IMAGE_IDS": ""}, working_directory: None, input_digests: InputDigests { complete: DirectoryDigest { digest: Digest { hash: Fingerprint<4bdb5dc82ac35992d61254127dd65421235d2e5c32dd9b87d8084144190c76>, size_bytes: 77 }, tree: "Some(..)" }, nailgun: DirectoryDigest { digest: Digest { hash: Fingerprint<e3b0c4429f8fc1c149afbf4c8996fb12441e4649b934ca495991c8852b855>, size_bytes: 0 }, tree: "Some(..)" }, input_files: DirectoryDigest { digest: Digest { hash: Fingerprint<4bdb5dc82ac35992fd67ed341274d123e5d2e5c32dd9b87d8084144190c76>, size_bytes: 77 }, tree: "Some(..)" }, immutable_inputs: {}, use_nailgun: {} }, output_files: {}, output_directories: {}, timeout: None, execution_slot_variable: None, concurrency_available: 0, description: "Building docker image <http://123454560.dkr.ecr.us-east-1.amazonaws.com/test_image:latest|123454560.dkr.ecr.us-east-1.amazonaws.com/test_image:latest>", level: Info, append_only_caches: {}, jdk_home: None, platform: Macos_arm64, cache_scope: PerSession, execution_strategy: Local, remote_cache_speculation_delay: 0ns }
Which seems to indicate to me that no environment variables from my pants.toml file are being passed through to the underlying docker build call (__UPSTREAM_IMAGE_IDS isn't one of my env vars).
I also tried clearing out my docker and pants caches to no avail.
Any potential workarounds are more than welcome in lieu of a direct fix, this is a bit of a blocker for me. Thanks for all your help and the really awesome tool.
Pants version
0.2.15
OS
MacOS, arm64
pantsbuild/pantscool-easter-32542
04/20/2023, 3:49 PM