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 without trailing newline is an error (?) #10459

Closed
justinsb opened this issue Dec 19, 2019 · 5 comments
Closed

bazelversion without trailing newline is an error (?) #10459

justinsb opened this issue Dec 19, 2019 · 5 comments
Labels
P1 I'll work on this now. (Assignee required) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug

Comments

@justinsb
Copy link
Contributor

justinsb commented Dec 19, 2019

Description of the problem / feature request:

After upgrading to bazel 2.0, bazel silently failed to launch. All bazel commands exited very quickly. I had a .bazelversion file with no newline at the end.

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

Create a .bazelversion file with "1.2.0" but no trailing newline; try running bazel, observe that it exits immediately.

What operating system are you running Bazel on?

Linux (I'm a googler if you want to contact me directly)

What's the output of bazel info release?

With .bazelversion of 1.2.0 without a newline it outputs nothing; with a newline it outputs:

bazel info release
INFO: Invocation ID: ee1bab32-42c3-400a-98cb-1293e0659e59
release 1.2.0

Not sure how helpful that is though! dpkg -l bazel tells me I am running the bazel package version 2.0.0.

Any other information, logs, or outputs that you want to share?

I believe the issue is that I have a .bazelversion file without a trailing newline. Adding a newline fixed the problem. (Proposed fix is in kubernetes/kops#8161)

The line in question (based on bash -x -v /usr/bin/bazel) seems to be this one:

read -r bazel_version < "${workspace_dir}/.bazelversion"

I did confirm that read -r foo < .bazelversion; echo $? gives 1 without the trailing newline, and 0 with a trailing newline, so this seems to match.

@jin
Copy link
Member

jin commented Dec 20, 2019

@meteorcloudy @philwo

@jin jin added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged labels Dec 20, 2019
@philwo philwo added P1 I'll work on this now. (Assignee required) type: bug and removed untriaged labels Jan 2, 2020
@philwo
Copy link
Member

philwo commented Jan 2, 2020

Ahh, good catch and sorry for the breakage. I will fix this and add a test case for it!

@konste
Copy link
Contributor

konste commented Feb 18, 2020

@philwo But why Bazel even read .bazelversion file? I thought it is only used by Bazelisk.

@philwo
Copy link
Member

philwo commented Mar 17, 2020

@konste Bazel itself doesn't read the .bazelversion file, but the bazel shell script that's installed as /usr/bin/bazel if you install Bazel using apt-get or a similar package manager does - this is intended to help people build projects with the correct Bazel version. Projects like TensorFlow had lots of issues with people trying to build it with a too old or too new version, because they weren't aware that you need a specific Bazel version.

@konste
Copy link
Contributor

konste commented Mar 17, 2020

Thank you, @philwo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required) 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