rules_go icon indicating copy to clipboard operation
rules_go copied to clipboard

go_repository fails to generate BUILD files for certain Go dependencies

Open Nickersoft opened this issue 3 years ago • 11 comments

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, 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, 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:

image

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

image

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

Nickersoft avatar Aug 01 '22 16:08 Nickersoft

I meet it too.

hawkingrei avatar Aug 27 '22 10:08 hawkingrei

Also running into this issue as well (for a project using carvel tools that imports this library), so an indirect dependency is causing this on my end.

ERROR: /root/.cache/bazel/_bazel_root/2e020ad50777956f5c6b506427fe5ab3/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 '//scripts/tcxctl:tcxctl' failed; build aborted: Analysis failed INFO: Elapsed time: 25.115s INFO: 0 processes. FAILED: Build did NOT complete successfully (768 packages loaded, 5363 targets configured) Fetching @io_k8s_helm; fetching 17s Fetching @com_github_docker_cli; fetching 10s Fetching @com_github_docker_docker; fetching 10s Fetching @com_github_azure_azure_sdk_for_go; fetching 8s Fetching @com_github_gregjones_httpcache; fetching Fetching @com_github_masterminds_goutils; fetching Fetching @com_github_lann_ps; fetching

connerqyang avatar Sep 08 '22 22:09 connerqyang

We add a patch to this dependency. It can work.

hawkingrei avatar Sep 09 '22 00:09 hawkingrei

We add a patch to this dependency. It can work.

I encountered this issue earlier today, do you mean there's been a fix since then? That commit/patch looks to be from 8 days ago.

connerqyang avatar Sep 09 '22 01:09 connerqyang

We add a patch to this dependency. It can work.

I encountered this issue earlier today, do you mean there's been a fix since then? That commit/patch looks to be from 8 days ago.

It just changed the bazel build file for com_github_rivo_uniseg which generated by gazelle. The best fix method is to fix the behavior of the gazelle.

hawkingrei avatar Sep 09 '22 01:09 hawkingrei

patch

Sorry I'm a bit confused. I'm still getting the same error that I pasted above that the BUILD file was not found in directory '' of external repository @com_github_rivo_uniseg. However, the patch you linked implies that BUILD file exists.

Could you help clear up my confusion? Thanks

connerqyang avatar Sep 09 '22 03:09 connerqyang

Was this issue ever resolved? I'm still seeing this error on my end -

ERROR: /home/ubuntu/.cache/bazel/_bazel_ubuntu/3bfad932a61b6ec3a65186104844629d/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'

Any help would be greatly appreciated!

archit-bedrock avatar Apr 04 '23 20:04 archit-bedrock

@archit-bedrock did you manage to fix your issue?

jayakasadev avatar Dec 21 '23 20:12 jayakasadev

@archit-bedrock did you manage to fix your issue?

No I don't think I was able to fix it.

archit-bedrock avatar Dec 21 '23 20:12 archit-bedrock

@archit-bedrock was there a workaround for you or did you have to use something else?

jayakasadev avatar Dec 21 '23 20:12 jayakasadev

in case someone circles back: using gazelle 0.33.0 fixed this for me

the newer versions require golang.org/x/tools > 0.10.0 which for some reason breaks update-repos

jayakasadev avatar Dec 21 '23 21:12 jayakasadev