bazel-gazelle icon indicating copy to clipboard operation
bazel-gazelle copied to clipboard

no such package '@@com_github_pingcap_tidb//pkg/parser/mysql': BUILD file not found in directory 'pkg/parser/mysql'

Open D3Hunter opened this issue 5 months ago • 0 comments

What version of gazelle are you using?

v0.38.0

What version of rules_go are you using?

v0.50.1

What version of Bazel are you using?

bazel 7.3.1

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

not tested

What operating system and processor architecture are you using?

macos

What did you do?

I am following this https://www.tweag.io/blog/2021-09-08-rules_go-gazelle/ to setup a simple bazel project.

I have a simple repo which has only one file and depends on tidb, which is also build with bazel

The file is like this

package main

import (
	"github.com/pingcap/tidb/pkg/kv"
	"github.com/pingcap/tidb/pkg/tablecodec"
	"github.com/pingcap/tidb/pkg/util/codec"
)

func main() {
	_ = codec.EncodeBytes(nil, tablecodec.EncodeRowKeyWithHandle(1, kv.IntHandle(0)))[:10]
}

When I try to build it, it report that BUILD file not found in directory 'pkg/parser/mysql' , but pkg/parser/mysql is actually another repo inside TiDB and TiDB replace it with github.com/pingcap/tidb/pkg/parser => ./pkg/parser. I guess the reason might be with the replace inside TiDB, but I cannot search any useful thing using google.

I have tried building other files which depends on github.com/docker/go-units, and it works.

bazel build //cmd/kv-regions

INFO: Invocation ID: 1d085997-19be-4f91-ac96-3d9650ed421b
ERROR: no such package '@@com_github_pingcap_tidb//pkg/parser/mysql': BUILD file not found in directory 'pkg/parser/mysql' of external repository @@com_github_pingcap_tidb. Add a BUILD file to a directory to mark it as a package.
ERROR: /private/var/tmp/_bazel_xxx/e4358c848742f2ce260860f15bf899aa/external/com_github_pingcap_tidb/pkg/util/codec/BUILD.bazel:3:11: no such package '@@com_github_pingcap_tidb//pkg/parser/mysql': BUILD file not found in directory 'pkg/parser/mysql' of external repository @@com_github_pingcap_tidb. Add a BUILD file to a directory to mark it as a package. and referenced by '@@com_github_pingcap_tidb//pkg/util/codec:codec'
ERROR: Analysis of target '//cmd/kv-regions:kv-regions' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.181s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully

What did you expect to see?

success

What did you see instead?

fail

D3Hunter avatar Sep 29 '24 13:09 D3Hunter