bazel-gazelle: Gazelle fails to run on Windows

I am using Windows 10 and Bazel 0.17.1.

Following the steps in https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel, on a new workspace, I get the following output:

$ bazel run //:gazelle --verbose_failures
INFO: Analysed target //:gazelle (34 packages loaded).
INFO: Found 1 target...
ERROR: C:/users/kamik/_bazel_kamik/mbmxo7xv/external/bazel_gazelle/internal/language/go/gen_std_package_list/BUILD.bazel:3:1: GoLink external/bazel_gazelle/internal/language/go/gen_std_package_list/windows_amd64_stripped/gen_std_package_list.exe failed (Exit 1): link.exe failed: error executing command
  cd C:/users/kamik/_bazel_kamik/mbmxo7xv/execroot/__main__
  SET CGO_ENABLED=1
    SET GOARCH=amd64
    SET GOOS=windows
    SET GOROOT=external/go_sdk
    SET GOROOT_FINAL=GOROOT
    SET PATH=C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64
  bazel-out/host/bin/external/io_bazel_rules_go/go/tools/builders/windows_amd64_stripped/link.exe -sdk external/go_sdk -installsuffix windows_amd64 -package_list bazel-out/host/bin/external/go_sdk/packages.txt -o bazel-out/host/bin/external/bazel_gazelle/internal/language/go/gen_std_package_list/windows_amd64_stripped/gen_std_package_list.exe -main bazel-out/host/bin/external/bazel_gazelle/internal/language/go/gen_std_package_list/windows_amd64_stripped/gen_std_package_list%/github.com/bazelbuild/bazel-gazelle/internal/language/go/gen_std_package_list.a -- -extld C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64/cl.exe -w -extldflags /MACHINE:X64
external\go_sdk\pkg\tool\windows_amd64\link.exe: cannot open file bazel-out/host/bin/external/bazel_gazelle/internal/language/go/gen_std_package_list/windows_amd64_stripped/gen_std_package_list%/github.com/bazelbuild/bazel-gazelle/internal/language/go/gen_std_package_list.a: open bazel-out/host/bin/external/bazel_gazelle/internal/language/go/gen_std_package_list/windows_amd64_stripped/gen_std_package_list%/github.com/bazelbuild/bazel-gazelle/internal/language/go/gen_std_package_list.a: The system cannot find the path specified.
GoLink: error running subcommand: exit status 2
Target //:gazelle failed to build
INFO: Elapsed time: 2.381s, Critical Path: 0.21s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

I’ve created a repo the the bare minimum of code and files to reproduce this in https://github.com/filipesilva/gazelle-windows.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Indeed, just realized the fix https://github.com/bazelbuild/bazel/commit/7aaa34a1ff518146dd972810445a3d8ced93aa27 is not included in 0.16.1 I’ll tell our CI team to upgrade bazel to 0.17.1 ASAP

@jayconrod tried with your commit:

$ bazel run //:gazelle
Starting local Bazel server and connecting to it...
INFO: SHA256 (https://github.com/bazelbuild/bazel-gazelle/archive/4c94784d65bc84a2b15a676e2e04d7300cb003b0.zip) = aa72267ceaf037ae78d945c683b6ecbf03bdf4ddae2715421c5bab00eabb75a8
INFO: Analysed target //:gazelle (41 packages loaded).
INFO: Found 1 target...
Target //:gazelle up-to-date:
  C:/users/kamik/_bazel_kamik/mbmxo7xv/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/gazelle-runner.bash
  C:/users/kamik/_bazel_kamik/mbmxo7xv/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/gazelle
  C:/users/kamik/_bazel_kamik/mbmxo7xv/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/gazelle.exe
INFO: Elapsed time: 25.196s, Critical Path: 0.38s
INFO: 0 processes.
INFO: Build completed successfully, 6 total actions
INFO: Build completed successfully, 6 total actions

Finishes successfully!

I think the other missing executables were just because native.sh_binary was not being used.

I also tried it on another repository (the main one where this came up, https://github.com/bazelbuild/rules_typescript), and it also seems to have run successfully:

$ bazel run //:gazelle
INFO: Build options have changed, discarding analysis cache.
INFO: Analysed target //:gazelle (39 packages loaded).
INFO: Found 1 target...
Target //:gazelle up-to-date:
  C:/users/kamik/_bazel_kamik/5c2rzegw/execroot/build_bazel_rules_typescript/bazel-out/x64_windows-fastbuild/bin/gazelle-runner.bash
  C:/users/kamik/_bazel_kamik/5c2rzegw/execroot/build_bazel_rules_typescript/bazel-out/x64_windows-fastbuild/bin/gazelle
  C:/users/kamik/_bazel_kamik/5c2rzegw/execroot/build_bazel_rules_typescript/bazel-out/x64_windows-fastbuild/bin/gazelle.exe
INFO: Elapsed time: 24.003s, Critical Path: 6.55s
INFO: 23 processes: 23 local.
INFO: Build completed successfully, 24 total actions
INFO: Build completed successfully, 24 total actions
gazelle: multiple rules (@build_bazel_rules_typescript//examples/protocol_buffers:tire_proto and @build_bazel_rules_typescript//examples/protocol_buffers:rules_typescript_proto) may be imported with "examples/protocol_buffers/tire.proto" from @build_bazel_rules_typescript//examples/protocol_buffers:rules_typescript_proto

Great work!