Skip to content

Commit fdedfc3

Browse files
authored
fix: load orion plugins relative to BUILD_WORKSPACE_DIRECTORY instead of cwd when run via bazel (#107)
### Changes are visible to end-users: no ### Test plan - Manual testing; running via `gazelle()` + multitool in bazel-examples repo
1 parent 7c29ebe commit fdedfc3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

language/orion/host.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,15 @@ func (h *GazelleHost) loadStarzellePlugins(plugins []string) {
9696
func (h *GazelleHost) loadEnvStarzellePlugins() {
9797
builtinPlugins := []string{}
9898

99-
// Load from cwd, or runfiles when running tests
99+
// Load relative to cwd by default
100100
builtinPluginDir, _ := os.Getwd()
101+
101102
if os.Getenv("BAZEL_TEST") != "" {
103+
// Load from runfiles when running in bazel tests
102104
builtinPluginDir = path.Join(os.Getenv("RUNFILES_DIR"), os.Getenv("TEST_WORKSPACE"))
105+
} else if workspaceDir := os.Getenv("BUILD_WORKSPACE_DIRECTORY"); workspaceDir != "" {
106+
// Load from bazel workspace root when run via bazel
107+
builtinPluginDir = workspaceDir
103108
}
104109

105110
// Comma-separated list of plugin paths relative to the workspace root

0 commit comments

Comments
 (0)