Skip to content

Commit a3128f1

Browse files
jgautier-ddjchadwick-buf
andauthored
Fix: pass in the repo root for the 'dir' argument (#119)
In tools that run bazel commands from within `bazel run` the `BUILD_WORKSPACE_DIRECTORY` will be set and then in this [code](https://github.com/bazel-contrib/bazel-gazelle/blob/master/cmd/gazelle/fix-update.go#L122-L139) the directory will eventually be set to the top level repo root. An example of a tool that this can happen to is the [gopackagesdriver](https://github.com/bazel-contrib/rules_go/wiki/Editor-setup) in rules_go. This results in error messages like: ``` no such package '@@rules_buf++buf+buf_deps//buf/validate': failed with code: 1, error: gazelle: .: not a subdirectory of repo root ``` By passing in additional argument it explicitly sets the `dir` to the directory of the repo. Gazelle itself does something [similar](https://github.com/bazel-contrib/bazel-gazelle/blob/6803436a9c39209bd56ea1dba2dddda323a3c98b/internal/go_repository.bzl#L363) Co-authored-by: jchadwick-buf <[email protected]>
1 parent 8bdf33e commit a3128f1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

buf/internal/repo.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def _buf_dependencies_impl(ctx):
7171
"fix",
7272
"-repo_root",
7373
ctx.path(""),
74+
ctx.path(""),
7475
]
7576
res = ctx.execute(cmd, quiet = False)
7677
if res.return_code != 0:

0 commit comments

Comments
 (0)