Hi all, I’m running into the following error with ...
# general
Hi all, I’m running into the following error with `./pants run Dockerfile`:
Copy code
BuildKit is enabled but the buildx component is missing or broken.
Install the buildx component to build images with BuildKit:
Notes: • I’m on an Intel-chip Macbook • I installed the most recent Docker Desktop • With
, I can run the
and the docker build succeeds with
(and the image appears in my docker desktop) It seems like my Docker installation is able to build with BuildKit enabled, but when running through Pants it doesn’t detect buildx? I’m new to Pants, so any direction would very appreciated! Let me know what other information I can provide. Thanks!
Hi Chris, This sounds like an issue with one or more env vars missing due to Pants hermetic execution model. Have you added
to your
in order for it to propagate to the docker build command, or did you provide that when you ran
might be that you need to have
set as well.. or something like that.
Hi Andreas! Yes, it is set:
Copy code
env_vars = ["DOCKER_BUILDKIT=1", ...]
When I try to run with
, I get this error:
Copy code
2023-05-08 11:14:26 Failed to find compatible interpreter on path /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin.
2023-05-08 11:14:26 
2023-05-08 11:14:26 Examined the following interpreters:
2023-05-08 11:14:26 1.) /usr/local/bin/python3.9 CPython==3.9.16
2023-05-08 11:14:26 2.)       /usr/bin/python3.9 CPython==3.9.2
2023-05-08 11:14:26 
2023-05-08 11:14:26 No interpreter compatible with the requested constraints was found:
2023-05-08 11:14:26 
2023-05-08 11:14:26   A distribution for apache-beam could not be resolved for /usr/local/bin/python3.9.
2023-05-08 11:14:26   Found 1 distribution for apache-beam that do not apply:
2023-05-08 11:14:26   1.) The wheel tags for apache-beam 2.44.0 are cp39-cp39-macosx_10_9_x86_64 which do not match the supported tags of /usr/local/bin/python3.9:
2023-05-08 11:14:26   cp39-cp39-manylinux_2_31_x86_64
2023-05-08 11:14:26   ... 661 more ...
A couple questions regarding this: 1. Where are these paths coming from (e.g.
)--this does not exist on my system; is this referring to paths inside the docker image? 2. Why is it selecting
? When I check my sysinfo from various python paths on my mac, I get
Are there more logs or more information I can provide you to help me understand which direction I should be looking?
that error message seems to come from running a pex inside a container, yes. One likely issue is that you built your pex on your Mac to run inside a container. That won’t work unless you take care to build the pex for the correct platform. See https://github.com/pantsbuild/pants/issues/14145 https://github.com/pantsbuild/pants/issues/13682 https://github.com/pantsbuild/pants/issues/13185
Ah okay thank you I will take a look at that!
@curved-television-6568 Hey! I’m still digging into this, but have a question for you in the meantime: Why is it that
./pants run Dockerfile
fails with
BuildKit is enabled but the buildx component is missing or broken
(no image is created), BUT when I go to the sandbox and run
(which runs
docker build
), the image builds successfully? Maybe relevant: Even though
successfully creates an image, subsequently running
docker run
on that image gives
Failed to find compatible interpreter on path
, which is the same error I get with
DOCKER_BUILDKIT=0 ./pants run Dockerfile
(mentioned above) Thanks for the help!
So, the
script you get in the sandbox is Pants best approximation of what it does when invoking that process. So if that works while Pants fails, there’s some little nuanced difference between the two, likely env var related.
Not sure about the interpreter issue. You’d want to make sure that the pex is trying to use the python you’d expect, and that there indeed exists such an interpreter in the image that it may use.
Alright, we upgraded to Pants 2.15 and we were able to fix the macOS to Linux cross-build issues with a
! 🎉 BUT…. I’m still running into this BuildKit/buildx issue 😕 Running
pants run Dockerfile
still gives the incessant
BuildKit is enabled but the buildx component is missing or broken.
error, despite definitely having buildx on my system, installed via Docker Desktop, and confirmed in
docker info
. Further, both of the following methods successfully build the docker image: 1. Run the
in the pants sandbox 2. Run my own bash script with all necessary
pants package
commands and
docker build
I cannot figure out why
pants run Dockerfile
is failing to detect buildx, while the other 2 approaches build the image without issue. Any guidance is greatly appreciated! Note:
pants run Dockerfile
does succeed if I set
In pants 2.15,
isn’t yet fully hermetic (ie doesn’t fully simulate running within pants itself ) and may be leaking some env vars from your shell. Does running
in a shell reveal any potentially docker relevant env vars?
I don’t see any env variables that would cause issues in this context, other than perhaps my PATH being different from what Pants uses? I’m on a mac using Docker Desktop. Does Pants use the local Docker installation, or does it have its own packaged binary? Since my local commands have no issues finding the buildx path, wouldn’t this be an issue with how Pants is constructing its environment (and not my env vars leaking in)?
it uses the system docker, doesn’t have it’s own binary. Try in a sandbox to change the env setup to use the
env -i …
that way, you get the same hermeticity as Pants.
in the
Forgot to follow up here: adding "HOME" to the env vars fixes the issue! (you alluded to this at the beginning of the thread haha but I got distracted by the other cross-platform issues I encountered) Thanks for the
env -i
tip! Using that, I found that it was indeed the HOME env var getting passed that allowed docker build to succeed when running
👍 1
Thanks for the follow up. Fwiw, starting with Pants 2.17 the
env -i
flag will be provided in the
script already. https://github.com/pantsbuild/pants/pull/18582
ah awesome! so with that change,
will fully reproduce the hermiticity of pants?