Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.bazelversion not being read in parent directory outside of WORKSPACE #523

Open
cpsauer opened this issue Dec 21, 2023 · 2 comments
Open
Labels
P2 We'll consider working on this in future. (Assignee optional) type:bug Something isn't working

Comments

@cpsauer
Copy link
Contributor

cpsauer commented Dec 21, 2023

Hi wonderful bazelisk folks,

First and foremost, thanks for a stupendous launcher. Bazelisk is really valuable and I really appreciate all the work you've done here.

I'm writing in to report a bug--or at least an instance where the docs are inconsistent with bazelisk's behavior.

The readme says:

Otherwise, if a .bazelversion file exists in the current directory or recursively any parent directory, it will read the file and use the version specified in it.

but Bazelisk seems to stop that search at a workspace boundary rather than any parent directory.

I think the documented behavior is probably the more desirable one. Projects often have a nested test workspace, and it'd be nice to inherit from the parent workspace. At least that was true of https://github.com/Neargye/magic_enum, where this was causing confusion. And I'd imagine any hardcoding of WORKSPACE files might need updating with the bzlmod changes, where a WORKSPACE file is no longer required. (But there might be other good reasons for the other behavior! In that case, the docs could use a change.)

Thanks so much for all you do,
Chris
(ex-Googler)

@cpsauer cpsauer changed the title Missing .bazelversion not being read in parent directory outside of WORKSPACE Dec 21, 2023
@fweikert fweikert added type:bug Something isn't working P2 We'll consider working on this in future. (Assignee optional) labels Jan 19, 2024
@avdv
Copy link

avdv commented May 3, 2024

I just stumbled over the same issue, but wanted to add that the file is also not read from the current directory if there is no WORKSPACE file.

In our case we want to check the users Bazel version for a start script and print out a warning if it's outside the expected version range, but on CI we want to use a fixed version so a .bazelversion file is created.

This happens before the start script is called, and causes bazelisk to download the latest Bazel version, which will currently result in a version warning, but the start script goes on to create a Bazel project at which point bazelisk switches to the configured version (downloading that) and uses that.

@mering
Copy link

mering commented May 13, 2024

Related: #502

avdv added a commit to tweag/rules_haskell that referenced this issue May 14, 2024
bazelisk does not read the `.bazelversion` file when there is no WORKSPACE and first fetches the latest Bazel version,
which causes a warning and later fetches the Bazel version specified in the `.bazelversion` file.

See bazelbuild/bazelisk#523
avdv added a commit to tweag/rules_haskell that referenced this issue May 24, 2024
bazelisk does not read the `.bazelversion` file when there is no WORKSPACE and first fetches the latest Bazel version,
which causes a warning and later fetches the Bazel version specified in the `.bazelversion` file.

See bazelbuild/bazelisk#523
avdv added a commit to tweag/rules_haskell that referenced this issue May 24, 2024
bazelisk does not read the `.bazelversion` file when there is no WORKSPACE and first fetches the latest Bazel version,
which causes a warning and later fetches the Bazel version specified in the `.bazelversion` file.

See bazelbuild/bazelisk#523
avdv added a commit to tweag/rules_haskell that referenced this issue May 24, 2024
bazelisk does not read the `.bazelversion` file when there is no WORKSPACE and first fetches the latest Bazel version,
which causes a warning and later fetches the Bazel version specified in the `.bazelversion` file.

See bazelbuild/bazelisk#523
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants