Search code examples
bazelbazel-rules

pkg_rules problems on Windows 10


I want to use rules_pkg

I have the following setup: Windows 10 x64 (Version 2004, Bazel 3.7.0, Visual Studio 16 2019, MSYS2 x86_64)

My minimal setup looks like this:

WORKSPACE.bazel

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# rules_pkg
http_archive(
    name = "rules_pkg",
    sha256 = "6b5969a7acd7b60c02f816773b06fcf32fbe8ba0c7919ccdc2df4f8fb923804a",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.3.0/rules_pkg-0.3.0.tar.gz",
        "https://github.com/bazelbuild/rules_pkg/releases/download/0.3.0/rules_pkg-0.3.0.tar.gz",
    ],
)

BUILD.bazel

load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")

cc_binary(
    name = "HelloWorld",
    srcs = ["main.cpp"],
)

pkg_tar(
    name = "deploy_HelloWorld",
    srcs = [
        ":HelloWorld",
    ],
    extension = "tar.gz",
)

main.cpp

#include <iostream>

int main() {
    std::cout << "Hello World!" << std::endl;
}

When I try to build i.e. bazel build //... I get:

PS G:\dev\BazelDemos\HelloWorld> bazel build //...
INFO: Analyzed 2 targets (20 packages loaded, 143 targets configured).
INFO: Found 2 targets...
ERROR: G:/dev/bazeldemos/helloworld/BUILD.bazel:8:8: PackageTar deploy_HelloWorld.tar.gz failed (Exit 9009): build_tar.exe failed: error executing command bazel-out/host/bin/external/bazel_tools/tools/build_defs/pkg/build_tar.exe --flagfile bazel-out/x64_windows-fastbuild/bin/deploy_HelloWorld.args
INFO: Elapsed time: 0.642s, Critical Path: 0.29s
INFO: 8 processes: 7 internal, 1 local.
FAILED: Build did NOT complete successfully

I can build without problems on two other Windows 10 machines with the same/similar setup. Any ideas?

More details to setup: Path containes C:\msys64\usr\bin. BAZEL_SH is set to C:\msys64\usr\bin\bash.exe.


Solution

  • Python3 was not installed in not in my Path variable. Exit 9009 refers usually to an error triggered by a batch script that fails to call a specific command.