Hi, in my pants project, I am installing a python ...
# general
a
Hi, in my pants project, I am installing a python package from an open git repository. Creating the lock file works and I can run
pants run my_project:bin
successfully. However, when I want to deploy my project (
pants package my_project
) it fails with
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
I already added git to the
docker_image
but that does not solve it. I feel there is must be an obvious way that I can't see yet, since I couldn't find anyone reporting a similar issue in this channel.
1
f
What package target are you using? I feel the need for the
git
executable must be explicitly stated using a runtime dependency with a
system_binary
.
b
The former command runs outside of the sandbox in your project root. The latter command runs inside a sandbox, isolated from the outside world. There's a config setting you can use to poke holes in the sandbox, but I'm forgetting which one it is. Maybe https://www.pantsbuild.org/2.20/reference/subsystems/pex#executable_search_paths?
a
Thank you for your answers. I dug into them but without success. I am still struggling to wrap my head around what actually is happening behind the scenes. I added in front of
python_sources
> system_binary( > name="git", > binary_name="git", > ) I also changed
binary_name="/usr/bin/git"
. But I still get the same error that git is not installed or not in my path.
b
Make sure the relevant target depends on that target. You can run your command with https://www.pantsbuild.org/2.20/reference/subsystems/pex#executable_search_paths
That should leak the sandbox which will have a shell script which loosely resembles the process pants ran
a
Thank you Josh. I now put in the following configuration - unfortunately without success pants.toml:
[pex]
executable_search_paths = ["/usr/bin/git"]
BUILD:
system_binary(
name="git",
binary_name="/usr/bin/git",
)
python_sources(dependencies=[":git"])
I might have found something. > pex_binary(..., environment="docker_linux") which in
pants.toml
is defined as > [environments-preview.names] > docker_linux = "//:docker_linux" If I change it to
local_linux
it works: > 153303.44 [DEBUG] Completed:
package
goal (I am not sure what that means though)
b
Is git installed in the docker image that the docker Linux target is pointing to?
👀 1
a
I guess it is this one:
docker_environment(
name="docker_linux",
platform="linux_x86_64",
image=f"python:{python_version}-slim-bullseye",
python_bootstrap_search_path=["/usr/local/bin"],
)
Maybe it is possible to give some instructions to the docker_environment?
b
Unfortunately, last I checked (which was admittedly a while ago) there wasn't a way to specify a local target for the
image=
. 😕
c
yep, there's an open feature request for that: https://github.com/pantsbuild/pants/issues/17714
a
Thanks y'all. We fixed it by using our local linux and not the docker_linux one. I appreciate your time and comments - without them I would have never found the cause. ❤️
🎉 1
👍 1