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

--workspace_status_command: handling of empty values is surprising and inconsistent #16037

Closed
lingithub1 opened this issue Aug 3, 2022 · 2 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob type: bug

Comments

@lingithub1
Copy link

lingithub1 commented Aug 3, 2022

Description of the bug:

If the workspace status command prints a line containing a key and a trailing space, this line will be copied to volatile-status.txt (or stable-statux.txt). This is OK.

If the workspace status command prints a line containing a key only, this line gets discarded. This is somewhat surprising and undocumented.

If the workspace status command prints a line containing a key without value as the last line of the output, this line gets discarded, even if there is a a trailing space after the key. This is surprising, undocumented and inconsistent with example #1.

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

Summary

My workspace status command:

#!/bin/bash
echo 'KEY_WITH_VALUE foo'
echo 'KEY_ONLY'
echo 'KEY_WITH_SPACE '
echo 'KEY_WITH_SPACE_AT_EOF '

My bazel-out/volatile-status.txt:

BUILD_TIMESTAMP 1659518612
KEY_WITH_SPACE
KEY_WITH_VALUE foo

Details

diff --git a/.bazelversion b/.bazelversion
new file mode 100644
index 0000000..91ff572
--- /dev/null
+++ b/.bazelversion
@@ -0,0 +1 @@
+5.2.0
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..f1fe42a
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,12 @@
+genrule(
+  name = 'my-test-gen',
+  executable = True,
+  stamp = 1,
+  outs = ['my-test'],
+  cmd = """
+echo "#!/bin/bash" > $@
+echo "cat <<'EOT'" >> $@
+cat bazel-out/volatile-status.txt >> $@
+echo EOT >> $@
+"""
+)
diff --git a/WORKSPACE b/WORKSPACE
new file mode 100644
index 0000000..e69de29
diff --git a/subdir/workspace-status b/subdir/workspace-status
new file mode 100755
index 0000000..4d94172
--- /dev/null
+++ b/subdir/workspace-status
@@ -0,0 +1,5 @@
+#!/bin/bash
+echo 'KEY_WITH_VALUE foo'
+echo 'KEY_ONLY'
+echo 'KEY_WITH_SPACE '
+echo 'KEY_WITH_SPACE_AT_EOF '
$ bazelisk run --workspace_status_command subdir/workspace-status my-test
[...]
INFO: Build completed successfully, 2 total actions
BUILD_TIMESTAMP 1659519173
KEY_WITH_SPACE
KEY_WITH_VALUE foo
$

Same problem on release 4.2.2.

Which operating system are you running Bazel on?

RHEL 7.9

What is the output of bazel info release?

5.2.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

I haven't found anything relevant, sorry, except the documentation (https://bazel.build/docs/user-manual#workspace-status):

The program should print zero or more key/value pairs to standard output, one entry on each line, then exit with zero (otherwise the build fails). The key names can be anything but they may only use upper case letters and underscores. The first space after the key name separates it from the value. The value is the rest of the line (including additional whitespaces). Neither the key nor the value may span multiple lines. Keys must not be duplicated.

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

No response

@brandjon brandjon added team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed team-Build-Language untriaged labels Nov 5, 2022
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 Jan 12, 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 Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob type: bug
Projects
None yet
Development

No branches or pull requests

3 participants