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 blocks query of 'bazel version' and bazel info release #11346

Closed
psigen opened this issue May 10, 2020 · 8 comments
Closed

.bazelversion blocks query of 'bazel version' and bazel info release #11346

psigen opened this issue May 10, 2020 · 8 comments
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug

Comments

@psigen
Copy link
Contributor

psigen commented May 10, 2020

Description of the problem / feature request:

The presence of a .bazelversion file that defines any non-matching version at the root of a directory structure prevents bazel from intepreting any commands in any subdirectory, including bazel version, help, info.

However, these are the commands needed to debug why .bazelversion is not satisfied, or to query non-build-related help information. For example, bazel info can only be run from a workspace.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. Create a new directory with two files:
  • .bazelversion
  • WORKSPACE
  1. In .bazelversion, put a clearly incompatible version string, e.g. 5.0.0.
  2. Run bazel version within this directory. Instead of returning the version, bazel will print:
$ bazel version
ERROR: The project you're trying to build requires Bazel 5.0.0 (specified in [...]/.bazelversion), but it wasn't found in /usr/bin.

You can install the required Bazel version via apt:
  sudo apt update && sudo apt install bazel-5.0.0

If this doesn't work, check Bazel's installation instructions for help:
  https://docs.bazel.build/versions/master/install-ubuntu.html
  1. This prevents querying version information from the bazel CLI from any subdirectory, which is what a developer would need to amend the .bazelversion file or debug a pathing issue (e.g. if a wrong installation of bazel is being used).

(As an interesting side note, while testing I accidentally created a blank WORKSPACE and incompatible .bazelversion file in my user home directory-- this blocked me from running bazel commands in any subdirectory that was not a workspace itself.)

What operating system are you running Bazel on?

Ubuntu 18.04 (also observed on OSX).

What's the output of bazel info release?

$ bazel info release
Starting local Bazel server and connecting to it...
release 3.1.0

Have you found anything relevant by searching the web?

Mentioned in #11264, which focuses on missing documentation for .bazelversion. It's fine to close this as a duplicate, I just wanted to specifically describe the usability issue.

@aiuto
Copy link
Contributor

aiuto commented May 13, 2020

That's a fun one. The behavior is both reasonably correct and blindingly stupid.

The same thing happens for bazel --version.
The fix might be relatively easy - ./scripts/packages/bazel.sh implements the check.

@aiuto aiuto added good first issue team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug untriaged labels May 13, 2020
@nikhilpothuru
Copy link

nikhilpothuru commented May 31, 2020

Hi, This is my first time working on the Bazel project. I wanted to ask some clarifying questions before I took on this issue. I was able to reproduce the problem as mentioned by psigen on OSX. I added an incompatible version string (i.e. 5.0.0) and I am unable to make queries like bazel version and bazel info release.

I downloaded the sample project from the "Introduction to Bazel: Building a Java Project" page and tried bazel version. This is what I got:

Build label: 3.2.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Wed May 27 17:58:08 2020 (1590602288)
Build timestamp: 1590602288
Build timestamp as int: 1590602288 

Do we want to check if the version string is invalid in the .bazelversion, and then send a proper output, with the most current build label?

Edit* I tried using the version string 3.1.0, and I got a similar error. I assume this is because I don't have bazel 3.1.0 installed. Is this the expected result?

@nikhilpothuru
Copy link

Hi,

I was able to get some clarification regarding what the output should be from psigen. I will take a look at how I can modify./scripts/packages/bazel.sh. Based on psigen's clarification, I will try to get the output to be similar to the output when there is no .bazelversion file at all.

-- Nikhil Pothuru

@philwo
Copy link
Member

philwo commented Dec 8, 2020

Thank you for your thoughts on this. Unfortunately I don't understand what your expected behavior is.

The output bazel version or bazel info of course depends on the version of Bazel that is invoked. The version of Bazel that is invoked is determined by the .bazelversion file. Thus, if the version that is referenced from that file is not installed, there is no way to print the correct output of bazel version or bazel info.

The error message seems sensible to me and I fail to see how you could end up with an "invalid" .bazelversion file in the first place?

@philwo philwo added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) and removed untriaged good first issue labels Dec 8, 2020
@github-actions
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 2+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Apr 18, 2023
@psigen
Copy link
Contributor Author

psigen commented Apr 18, 2023

Would it be possible to amend the error message to include meta-information about available versions of bazel?

Also I am a bit unclear, is this message coming from bazel or from bazelisk? Maybe this issue need to be moved there?

Many other compilers and packaging systems have benefited from adding hints around valid values into their error messages. It could be similarly helpful here.

@github-actions github-actions bot removed the stale Issues or PRs that are stale (no activity for 30 days) label Apr 19, 2023
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Jun 23, 2024
Copy link

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please post @bazelbuild/triage in a comment here and we'll take a look. Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug
Projects
None yet
Development

No branches or pull requests

4 participants