bazel-contrib / bazel-contrib/rules_go
go_repository fails to generate BUILD files for certain Go dependencies
- 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?
0.34.0
### What version of gazelle are you using?
0.26.0
### What version of Bazel are you using?
5.2.0
### Does this issue reproduce with the latest releases of all the above?
Yes
### What operating system and processor architecture are you using?
OS Version: macOS
System Version: 12.3.1
Build Version: 21E258
Architecture: ARM (M1)
### What did you do?
1. Ran `bazel run gazelle` and `bazel run update-repos`
2. Attempted to build a Go target
3. Received `BUILD file not found in directory '' of external repository @com_github_rivo_uniseg. Add a BUILD file to a directory to mark it as a package.`
This error is reproducible if you check out my [open source repo](https://github.com/TheOpenDictionary/odict), switch over to the `nickersoft/final` branch, and run `bazel build go`. You'll notice that the generated Go repository it is mentioning does not contain a BUILD file, which is causing the error. The only similar issue I have found to this [is this one](https://github.com/bazelbuild/rules_go/issues/2510), though the fixes over there don't seem to work for me.
### Additional Info
The full error is:
```
ERROR: /private/var/tmp/_bazel_tjnickerson/6f441a2e0b83f1b25dbd79b8c892f6eb/external/com_github_mattn_go_runewidth/BUILD.bazel:3:11: no such package '@com_github_rivo_uniseg//': BUILD file not found in directory '' of external repository @com_github_rivo_uniseg. Add a BUILD file to a directory to mark it as a package. and referenced by '@com_github_mattn_go_runewidth//:go-runewidth'
ERROR: Analysis of target '//bridge:bridge' failed; build aborted: no such package '@com_github_rivo_uniseg//': BUILD file not found in directory '' of external repository @com_github_rivo_uniseg. Add a BUILD file to a directory to mark it as a package.
```
The referencing target:

The `com_github_rivo_uniseg` directory, that contains a `WORKSPACE` but no `BUILD` files:

### What did you expect to see?
I expected everything generated by Gazelle to work out-of-the-box, without having to create my own BUILD files.
### What did you see instead?
The above error lol
Contributor guide
Research direction
Reproduce the failure in the linked odict repository on the nickersoft/final branch with `bazel run gazelle`, `bazel run update-repos`, and `bazel build go`. Inspect the generated `com_github_rivo_uniseg` external repository and its reference from `com_github_mattn_go_runewidth/BUILD.bazel`; done means generated repositories contain the BUILD files needed for the target to build.
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
- Mostly clear
- Newbie friendliness
- 35/100