Skip to content

Look for config files anywhere up the tree - #805

Open
keith wants to merge 1 commit into
bazelbuild:masterfrom
keith:ks/look-for-config-files-anywhere-up-the-tree
Open

keith wants to merge 1 commit into
bazelbuild:masterfrom
keith:ks/look-for-config-files-anywhere-up-the-tree

Conversation

@keith

@keith keith commented Jul 15, 2026

Copy link
Copy Markdown
Member

Previously the README said that bazelisk would discover the
.bazelversion file "in the current directory or recursively any parent
directory", but this wasn't the case. It would only find it in the root
of the project. This doesn't work for cases where users have this layout
for testing:

repo/MODULE.bazel
repo/.bazelversion
repo/e2e/MODULE.bazel

In this case it would only look beside repo/e2e/MODULE.bazel, not find
the repo/.bazelversion and fallback to other logic. Folks often fix
this by symlinking the root .bazelversion to the subdirectory.

This changes the behavior to do what was stated before. The new behavior
applies for the .bazeliskrc too.

Fixes #52
Fixes #523

Previously the README said that bazelisk would discover the
`.bazelversion` file "in the current directory or recursively any parent
directory", but this wasn't the case. It would only find it in the root
of the project. This doesn't work for cases where users have this layout
for testing:

```
repo/MODULE.bazel
repo/.bazelversion
repo/e2e/MODULE.bazel
```

In this case it would only look beside `repo/e2e/MODULE.bazel`, not find
the `repo/.bazelversion` and fallback to other logic. Folks often fix
this by symlinking the root `.bazelversion` to the subdirectory.

This changes the behavior to do what was stated before. The new behavior
applies for the `.bazeliskrc` too.

Fixes bazelbuild#52
Fixes bazelbuild#523
@keith

keith commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

I chose not to touch repo/tools/bazel discovery here since that felt a bit weird to do recursively up, but maybe that leads to more confusion?

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.

.bazelversion not being read in parent directory outside of WORKSPACE Version in .bazelversion should be respected without WORKSPACE file

3 participants