Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go_repository fails to generate BUILD files for certain Go dependencies #3259

Open
Nickersoft opened this issue Aug 1, 2022 · 11 comments
Open

Comments

@Nickersoft
Copy link

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

@hawkingrei
Copy link
Contributor

I meet it too.

@connerqyang
Copy link

connerqyang commented Sep 8, 2022

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

@hawkingrei
Copy link
Contributor

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

@connerqyang
Copy link

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.

@hawkingrei
Copy link
Contributor

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.

@connerqyang
Copy link

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

@archit-bedrock
Copy link

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!

@jayakasadev
Copy link

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

@archit-bedrock
Copy link

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

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

@jayakasadev
Copy link

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

@jayakasadev
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants