Open lbhdc opened 2 years ago
I'm having the same problem. Have you managed to find a solution?
@tuananhlai I have a workaround, but not a great one.
I have a wrapper around gazelle that runs go mod tidy, updates repos, then runs gazelle. I added a call to sed to do a find and replace for on the specific build file that I am having this problem in.
Here is what it looks like
#! /usr/bin/env bash
go mod tidy
bazel run //:gazelle-update-repos
bazel run //:gazelle
sed -i 's,@com_github_bytecodealliance_wasmtime_go//:wasmtime-go,@com_github_bytecodealliance_wasmtime_go//:go_default_library,g' path/to/BUILD
This is less than ideal though. If the wrapper isn't used then you run right back into this edge case.
Sounds to me like there is something wrong with the way your gazelle:go_naming_convention
is getting inferred. The value you see (:wasmtime-go
) is what I'd expect from the import
mode Do you have anything that is configuring that setting?
@achew22 that is what I would expect too based on the import.
In my root BUILD
i have a few magic comment directives, but nothing (that I am aware of) that would change the naming convention.
# gazelle:prefix my-project
# gazelle:build_file_name BUILD
# gazelle:exclude bazel-*
# gazelle:exclude cmake-*
# gazelle:exclude third_party
# gazelle:exclude tools
gazelle(name = "gazelle")
Perhaps one complication is that this libraries package name is different from its github path? For example it uses package wasmtime
instead of package wasmtime-go
. This package name is the same as the cc_library target in that package. I wonder if that is causing part of the problem?
What version of gazelle are you using?
0.25.0
What version of rules_go are you using?
0.33.0
What version of Bazel are you using?
5.1.1
Does this issue reproduce with the latest releases of all the above?
Yes
What operating system and processor architecture are you using?
Linux x86_64
What did you do?
I am trying to incorporate wasmtime into my project. However, it generates the incorrect bazel path when generating build files.
Simple example main.go
This is how I am configuring my gazelle commands
Then update dependencies, and generate build files
The wasmtime library calls out a
go_repository
rule in their docs. gazelle generates the identical rule.What did you expect to see?
This isn't what I expected, but this is correct.
What did you see instead?
This is the path that gazelle generates.
This fails to build, bazel complains it can't find that path, and exploring what targets are available confirm that
:wasmtime-go
doesn't exist.I wonder if it has something to do with the cc target?
Is there a way to prevent this?