pants icon indicating copy to clipboard operation
pants copied to clipboard

pants doesn't respect url directives in global gitconfig

Open rdeusser opened this issue 1 year ago • 2 comments

Describe the bug This directive in my global gitconfig is not respected:

[url "ssh://git@<private-scm>/"]
	insteadOf = https://<private-scm>/

Pants version Tried both 2.16.0 and 2.17.0rc1

OS macOS Ventura (13.4.1)

Additional info Output from pants:

ProcessExecutionFailure: Process 'Download Go module <private-scm/org/module>@v0.1.0.' failed with exit code 1.
stdout:
{
	"Path": "<private-scm/org/module>",
	"Version": "v0.1.0",
	"Error": "<private-scm/org/module>@v0.1.0: invalid version: git ls-remote -q origin in /private/var/folders/hr/5_qsxyej01b393wrfxq7hp2h0000gn/T/pants-sandbox-Hx6pgc/gopath/pkg/mod/cache/vcs/e1f2e5787ba54003b17b3bc74ebc50bf7e300f8cd2bc05d2ee20346a1f77d658: exit status 128:\n\tfatal: could not read Username for 'https://<private-scm>': terminal prompts disabled\nConfirm the import path was entered correctly.\nIf this is a private repository, see https://golang.org/doc/faq#git_https for additional information."
}

I've looked everywhere in the docs for git or ssh and I can't find anything that mentions this. I checked the issues and I found https://github.com/pantsbuild/pants/issues/18563, but that only mentioned global gitignore rules.

rdeusser avatar Jul 06 '23 16:07 rdeusser

Welcome to the Pantsbuild Community. This looks like your first issue here. Thanks for taking the time to write it.

If you haven't already, feel free to come say hi on Slack.

If you have questions, or just want to surface this issue, check out the #development channel. (If you want to check it out without logging in, check out our Linen mirror)

Thanks again, and we look forward to your next Issue/PR :smile:!

WorkerPants avatar Jul 06 '23 16:07 WorkerPants

I've managed to solve this problem using subprocess_env_vars.

Make sure to set the GOPRIVATE and GIT_CONFIG_GLOBAL env vars, along with the default ones: Example:

[golang]
subprocess_env_vars = [
  "LANG",
  "LC_CTYPE",
  "LC_ALL",
  "PATH",
  "GOPRIVATE=github.com/<your_org>",
  "GIT_CONFIG_GLOBAL=/home/user/.gitconfig"
]

In your .gitconfig you'll need to configure git to use ssh instead of https like so:

[url "ssh://[email protected]/"]
	insteadOf = https://github.com/

FilipNikolovski avatar Feb 12 '24 19:02 FilipNikolovski