bazelbuild / bazelbuild/bazel

workspace_status_command cannot live in root of workspace

Open
#14,861 6 comments 1 reaction 0 assignees View on GitHub
not stale P4 team-Loading-API type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description of the problem / feature request:

If a script exists in the root of a workspace, it can't be used as a `--workspace_status_command` value.

If specifying `--workspace_status_command=foo.sh` then `foo.sh` will be looked up in `$PATH` but not the working directory.

If specifying `--workspace_status_command=./foo.sh` then [the option](https://github.com/bazelbuild/bazel/blob/8d2c45c5aabb3fceb67e433e89895883e9228daf/src/main/java/com/google/devtools/build/lib/analysis/WorkspaceStatusAction.java#L78-L90) is normalized using the `PathFragmentConverter` to `foo.sh` and the same behaviour is observed.

I would expect at least the second, if not both of the above commands, to work. Perhaps there's some behaviour possible where the working directory is searched _before_ `$PATH`? Alternatively, if we treated the option as a String, that would at least make the `./foo.sh` version work.

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

```console
% touch WORKSPACE
% cat > BUILD < status.sh <: BazelWorkspaceStatusAction stable-status.txt failed: Failed to determine workspace status: Process exited with status 127
/bin/sh: status.sh: command not found
Target //:gr failed to build
Use --verbose_failures to see the command lines of failed build steps.
```

### What operating system are you running Bazel on?

macOS

### What's the output of `bazel info release`?

release 5.0.0

Contributor guide

Open the contributing guide

Research direction

Start with src/main/java/com/google/devtools/build/lib/analysis/WorkspaceStatusAction.java and the referenced PathFragmentConverter behavior. Reproduce the issue with the provided WORKSPACE, BUILD, and status.sh example using --workspace_status_command=./status.sh, then verify that the command resolves from the workspace root and the build produces FOO 1.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.