Skip to content

Commit 67da3e5

Browse files
authored
fix: gazelle: Fix non-hermetic runfiles lookup (bazel-contrib#1415)
`bazel.Runfiles` is a deprecated way to look up runfiles that can result in non-hermetic lookups. `github.com/bazelbuild/rules_go/go/runfiles` is the recommended package for this.
1 parent 4769fea commit 67da3e5

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

gazelle/MODULE.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module(
66

77
bazel_dep(name = "rules_python", version = "0.18.0")
88
bazel_dep(name = "rules_go", version = "0.41.0", repo_name = "io_bazel_rules_go")
9-
bazel_dep(name = "gazelle", version = "0.31.0", repo_name = "bazel_gazelle")
9+
bazel_dep(name = "gazelle", version = "0.33.0", repo_name = "bazel_gazelle")
1010

1111
go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps")
1212
go_deps.from_file(go_mod = "//:go.mod")

gazelle/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.19
55
require (
66
github.com/bazelbuild/bazel-gazelle v0.31.1
77
github.com/bazelbuild/buildtools v0.0.0-20230510134650-37bd1811516d
8-
github.com/bazelbuild/rules_go v0.39.1
8+
github.com/bazelbuild/rules_go v0.41.0
99
github.com/bmatcuk/doublestar v1.3.4
1010
github.com/emirpasic/gods v1.18.1
1111
github.com/ghodss/yaml v1.0.0

gazelle/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/bazelbuild/bazel-gazelle v0.31.1 h1:ROyUyUHzoEdvoOs1e0haxJx1l5EjZX6AO
44
github.com/bazelbuild/bazel-gazelle v0.31.1/go.mod h1:Ul0pqz50f5wxz0QNzsZ+mrEu4AVAVJZEB5xLnHgIG9c=
55
github.com/bazelbuild/buildtools v0.0.0-20230510134650-37bd1811516d h1:Fl1FfItZp34QIQmmDTbZXHB5XA6JfbNNfH7tRRGWvQo=
66
github.com/bazelbuild/buildtools v0.0.0-20230510134650-37bd1811516d/go.mod h1:689QdV3hBP7Vo9dJMmzhoYIyo/9iMhEmHkJcnaPRCbo=
7-
github.com/bazelbuild/rules_go v0.39.1 h1:wkJLUDx59dntWMghuL8++GteoU1To6sRoKJXuyFtmf8=
8-
github.com/bazelbuild/rules_go v0.39.1/go.mod h1:TMHmtfpvyfsxaqfL9WnahCsXMWDMICTw7XeK9yVb+YU=
7+
github.com/bazelbuild/rules_go v0.41.0 h1:JzlRxsFNhlX+g4drDRPhIaU5H5LnI978wdMJ0vK4I+k=
8+
github.com/bazelbuild/rules_go v0.41.0/go.mod h1:TMHmtfpvyfsxaqfL9WnahCsXMWDMICTw7XeK9yVb+YU=
99
github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
1010
github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
1111
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=

gazelle/python/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ go_library(
3636
"@com_github_emirpasic_gods//lists/singlylinkedlist",
3737
"@com_github_emirpasic_gods//sets/treeset",
3838
"@com_github_emirpasic_gods//utils",
39-
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
39+
"@io_bazel_rules_go//go/runfiles",
4040
],
4141
)
4242

gazelle/python/parser.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"strings"
2727
"sync"
2828

29-
"github.com/bazelbuild/rules_go/go/tools/bazel"
29+
"github.com/bazelbuild/rules_go/go/runfiles"
3030
"github.com/emirpasic/gods/sets/treeset"
3131
godsutils "github.com/emirpasic/gods/utils"
3232
)
@@ -38,7 +38,7 @@ var (
3838
)
3939

4040
func startParserProcess(ctx context.Context) {
41-
parseScriptRunfile, err := bazel.Runfile("python/parse")
41+
parseScriptRunfile, err := runfiles.Rlocation("rules_python_gazelle_plugin/python/parse")
4242
if err != nil {
4343
log.Printf("failed to initialize parser: %v\n", err)
4444
os.Exit(1)

gazelle/python/std_modules.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"strings"
2727
"sync"
2828

29-
"github.com/bazelbuild/rules_go/go/tools/bazel"
29+
"github.com/bazelbuild/rules_go/go/runfiles"
3030
)
3131

3232
var (
@@ -39,7 +39,7 @@ var (
3939
func startStdModuleProcess(ctx context.Context) {
4040
stdModulesSeen = make(map[string]struct{})
4141

42-
stdModulesScriptRunfile, err := bazel.Runfile("python/std_modules")
42+
stdModulesScriptRunfile, err := runfiles.Rlocation("rules_python_gazelle_plugin/python/std_modules")
4343
if err != nil {
4444
log.Printf("failed to initialize std_modules: %v\n", err)
4545
os.Exit(1)

0 commit comments

Comments
 (0)