bazel-contrib / bazel-contrib/rules_go

fatal: Could not read from remote repository (private repository)

Open
#3,584 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1.5k
Forks
760
Avg merge
1d 11h
Merged PRs (30d)
12

Description

### What version of rules_go are you using?

rules_go = v0.35.0

### What version of gazelle are you using?

gazelle = v0.28.0

### What version of Bazel are you using?

bazel = 5.4.0

### Does this issue reproduce with the latest releases of all the above?

Not sure

### What operating system and processor architecture are you using?

linux / amd64

### What did you do?

I'm trying to add the golang toolchain to a private mono-repository.

I configured gazelle with following prefix :
```
# gazelle:prefix gitlab.xxx.com/yyy/zzz
```

My golang code needs to import a protobuf from the same repository. Using gazelle I have this target :
```
# Protobuf target located in src/logs/exporter
go_library(
name = "logs",
srcs = [
"hrd.h",
],
embed = [":logs_go_proto"],
importpath = "gitlab.xxx.com/yyy/zzz/src/logs/exporter",
visibility = ["//visibility:public"],
)

# Golang code target located in src/logs/archiver
go_library(
name = "archiver_lib",
srcs = ["main.go"],
importpath = "gitlab.xxx.com/yyy/zzz/src/logs/archiver",
visibility = ["//visibility:public"],
deps = [
"//src/logs/exporter:logs",
"@com_google_cloud_go_storage//:storage",
"@org_golang_google_grpc//:grpc",
"@org_golang_google_grpc//reflection",
"@org_golang_google_grpc//status",
"@org_golang_google_protobuf//types/known/timestamppb",
],
)
```

I also configured git to use ssh to access the repo :
```
# In ~/.gitconfig
[url "ssh://gitlab.xxx.com/"]
insteadOf = https://gitlab.xxx.com/
```

Then I init go.mod with the golang toolchain fetched by bazel :
```
bazel run @go_sdk//:bin/go -- mod init gitlab.xxx.com/yyy/zzz
```
### What did you expect to see?

A working mod tidy

### What did you see instead?
Unfortunately, I cannot use go mod tidy :
```
go: finding module for package gitlab.xxx.com/yyy/zzz/src/logs/exporter
gitlab.xxx.com/yyy/zzz/src/logs/archiver imports
gitlab.xxx.com/yyy/zzz/src/logs/exporter: module gitlab.xxx.com/yyy/zzz/src/logs/exporter: git ls-remote -q origin in /home/xxx/go/pkg/mod/cache/vcs/4054939e8947a22078fedd0481c6c802394fb7f63f0d4d1d82c956575bd3041c: exit status 128:
bash: git-upload-pack: command not found
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
```

Executing git ls-remote locally works, I don't know why the bazel sandbox cannot authenticate to my private repository.

Honestly, I'm not sure if this should be an issue or a StackOverflow question, please let me know if this is not the appropriate space.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing `go mod tidy` through the Bazel-fetched `@go_sdk` toolchain using the shown private import and compare it with the locally working `git ls-remote`. Inspect the `~/.gitconfig` SSH rewrite and the displayed rules_go targets; done means the private repository dependency resolves without the sandbox authentication error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.