Skip to content

bazeliskNpmPath: should check if @bazel/bazelisk binary exists? #370

Closed
@ztl8702

Description

I recently had an issue where if I run @bazel/ibazel using yarn ibazel (or npn bazel) it would attempt to locate @bazel/bazelisk (and fail) even though I did not install @bazel/bazelisk.

Steps to reproduce

Assuming bazel is already in PATH.

  1. Create an empty directory
  2. Run yarn init
  3. Run yarn install -D @bazel/ibazel
  4. Add dummy BUILD and WORKSPACE
  5. Run yarn ibazel build //...

Expected result: build succeeds

Actual result:

$ yarn ibazel build //...
yarn run v1.13.0
$ /private/tmp/bazelisk/node_modules/.bin/ibazel build //...
iBazel [2:56AM]: Error getting Bazel info fork/exec /private/tmp/bazelisk/node_modules/@bazel/bazelisk/bazelisk-darwin_amd64: no such file or directory
iBazel [2:56AM]: Querying for files to watch...
iBazel [2:56AM]: Bazel query failed: fork/exec /private/tmp/bazelisk/node_modules/@bazel/bazelisk/bazelisk-darwin_amd64: no such file or directory
iBazel [2:56AM]: Bazel query failed: fork/exec /private/tmp/bazelisk/node_modules/@bazel/bazelisk/bazelisk-darwin_amd64: no such file or directory
iBazel [2:56AM]: Building //...
iBazel [2:56AM]: Build error: fork/exec /private/tmp/bazelisk/node_modules/@bazel/bazelisk/bazelisk-darwin_amd64: no such file or directory
iBazel [2:56AM]: Error reading config: open .bazel_fix_commands.json: no such file or directory
iBazel [2:56AM]: Use default regex
^C

Looking at

func bazeliskNpmPath(ibazelBinPath string) (string, error) {
, it seems that the code only builds the path for node_modules/@bazel/bazelisk/bazelizk-darwin_amd64 but does not check if the binary actually exists.

So the fix should be simply adding a os.Stat check?


bazel version:

Build label: 2.2.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Mar 3 09:28:15 2020 (1583227695)
Build timestamp: 1583227695
Build timestamp as int: 1583227695

iBazel - Version v0.12.3

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions