<#21292 pants fails to download golang module from...
# github-notifications
c
#21292 pants fails to download golang module from private repo due to missing git binary Issue created by henri14 Describe the bug pants cannot use a golang module in a private repo due to the git binary not being available in the sandbox. go mod download needs the git binary for modules in private repositories
Copy code
pants package consumer::
21:56:23.94 [INFO] Initializing scheduler...
21:56:24.19 [INFO] Scheduler initialized.
21:56:24.50 [ERROR] 1 Exception encountered:

Engine traceback:
  in `package` goal

ProcessExecutionFailure: Process 'Download Go module <http://github.com/henri14/simple-module/hello@v0.0.2|github.com/henri14/simple-module/hello@v0.0.2>.' failed with exit code 1.
stdout:
{
        "Path": "<http://github.com/henri14/simple-module/hello|github.com/henri14/simple-module/hello>",
        "Version": "v0.0.2",
        "Error": "<http://github.com/henri14/simple-module/hello@v0.0.2|github.com/henri14/simple-module/hello@v0.0.2>: git init --bare in /tmp/pants-sandbox-d3zlVC/gopath/pkg/mod/cache/vcs/3650a5475de977aabb40e7fc1653b859d9ac6936337ccb79dac03b750edcc192: exec: \"git\": executable file not found in $PATH"
}
Pants version 2.21.1 OS "Ubuntu 22.04.3 LTS" using WSL2 Additional info Related to #12625 I have a simple fix which is to add GitBinary to the setup_go_sdk_process rule in pants/src/python/pants/backend/go/util_rules/sdk.py Line 106 in</pantsbuild/pants/commit/4553e4cbaa702aedd5e78bc3901ff3d7fdf57b94|4553e4c> | async def setup_go_sdk_process( | | ------------------------------- | I have a simple repo that I used to reproduce the issue: https://github.com/henri14/simple-consumer pants.toml
Copy code
[GLOBAL]
pants_version = "2.21.1"
backend_packages.add = [
  "pants.backend.experimental.go",
]


[golang]
cgo_enabled = false
subprocess_env_vars = [
    'GOPRIVATE=<http://github.com/henri14/simple-module/*|github.com/henri14/simple-module/*>',
    'HOME',
]
go get - with GOPRIVATE set
Copy code
export GOPRIVATE=<http://github.com/henri14/simple-module/*|github.com/henri14/simple-module/*>
/simple-consumer/consumer$ go get <http://github.com/henri14/simple-module/hello@v0.0.2|github.com/henri14/simple-module/hello@v0.0.2>
go: downloading <http://github.com/henri14/simple-module/hello|github.com/henri14/simple-module/hello> v0.0.2
go: added <http://github.com/henri14/simple-module/hello|github.com/henri14/simple-module/hello> v0.0.2
pantsbuild/pants