Skip to content

Conversation

fzakaria
Copy link
Contributor

If you don't want workspace enabled and are on version 8, unused_deps did not work due to the lack of workspace support.

You could either fix this by adding it to your project's bazelrc however we conditionally enable it here depending on the version of bazel being executed.

This does have the side-effect that it seems to cause a rebuild due to the arguments of the CLI changing.

If you don't want workspace enabled and are on version 8, unused_deps
did not work due to the lack of workspace support.

You could either fix this by adding it to your project's bazelrc however
we conditionally enable it here depending on the version of bazel being
executed.

This does have the side-effect that it seems to cause a rebuild due to
the arguments of the CLI changing.
Comment on lines +86 to +109
func bazelMajorVersion() (int, error) {
out, err := cmdWithStderr(*buildTool, "version").Output()
if err != nil {
return 0, err
}
lines := strings.Split(string(out), "\n")
for _, line := range lines {
if strings.HasPrefix(line, "Build label: ") {
version := strings.TrimPrefix(line, "Build label: ")
parts := strings.Split(version, ".")
if len(parts) < 1 {
return 0, fmt.Errorf("could not parse version from 'bazel version' output: %s", version)
}
var major int
_, err := fmt.Sscanf(parts[0], "%d", &major)
if err != nil {
return 0, fmt.Errorf("could not parse major version from 'bazel version' output: %s", version)
}
return major, nil
}
}
return 0, errors.New("could not find version in 'bazel version' output")
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also use this to conditionally, create a MODULE.bazel file and then use override_module instead of repository; I guess both approaches could work and that would probably needed eventually for Bazel 9+ when WORKSPACE is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant