rules-proto-grpc / rules_proto_grpc

Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets
https://rules-proto-grpc.com
Apache License 2.0
249 stars 156 forks source link

Windows 11 - Bazel 6.4.0 - Rules Proto 4.6.0 - You seem to have passed an empty string as one of the arguments to protoc.exe #308

Closed emilbon99 closed 7 months ago

emilbon99 commented 7 months ago

Issue Description

On Windows, when I run bazel build //:service_proto_cc --verbose_failures in the provided demo repo, the build process results in an error stating that ''You seem to have passed an empty string as one of the arguments to protoc.exe. This is actually sort of hard to do. Congrats. Unfortunately it is not valid input so the program is going to die now." (See attached logs). In my digging I found this pull request: https://github.com/rules-proto-grpc/rules_proto_grpc/pull/221 that mentions quote escaping the "$@" line. An interesting note is that when I open up a bash terminal and copy and run this command manually, everything works fine.

Log Output

bazel build //:service_grpc --verbose_failures
INFO: Build option --enable_runfiles has changed, discarding analysis cache.
INFO: Analyzed target //:service_grpc (134 packages loaded, 4271 targets configured).
INFO: Found 1 target...
INFO: From Compiling upb/arena.c:
ERROR: C:/users/synnax/desktop/synnaxlabs/playground/BUILD.bazel:19:17: Compiling protoc outputs for cpp_plugin plugin on target @//:service_grpc_pb failed: (Exit 1): bash.exe failed: error executing command (from target //:service_grpc_pb)
  cd /d C:/bazel-tmp/ow7fbzd4/execroot/__main__
  SET BAZEL_CXXOPTS=-std=c++17
    SET PATH=C:\Users\Synnax\AppData\Local\Microsoft\WindowsApps;C:\WINDOWS;C:\WINDOWS\System32;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Users\Synnax\AppData\Local\bazelisk\downloads\sha256\ff94279f7de7ec604c40b5d760f0dc10bdc880f07e915adced825f53e5f4fa1b\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\ProgramData\nvm;C:\Program Files\nodejs;C:\Program Files\GitHub CLI\;C:\Users\Synnax\AppData\Local\pnpm;C:\Program Files\Go\bin;C:\Program Files\dotnet\;C:\Program Files\PowerShell\7\;C:\Program Files\Git\cmd;C:\Users\Synnax\AppData\Local\pnpm;C:\Users\Synnax\.cargo\bin;C:\Users\Synnax\AppData\Local\Microsoft\WindowsApps;C:\Users\Synnax\AppData\Local\JetBrains\Toolbox\scripts;C:\Users\Synnax\AppData\Local\Programs\Microsoft VS Code\bin;C:\ProgramData\nvm;C:\Program Files\nodejs;C:\Users\Synnax\AppData\Local\pnpm;C:\Users\Synnax\AppData\Local\Programs\Python\Python311;C:\Users\Synnax\AppData\Local\Programs\Python\Python311\Scripts;C:\Users\Synnax\AppData\Roaming\Python\Scripts;C:\Users\Synnax\go\bin;C:\Program Files (x86)\GnuWin32\bin;C:\msys64\ucrt64\bin;
  C:\Users\Synnax\AppData\Local\Microsoft\WindowsApps\bash.exe -c mkdir -p 'bazel-out/x64_windows-fastbuild/bin/_rpg_premerge_service_grpc_pb' && bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/protoc.exe "$@"  --descriptor_set_in=bazel-out/x64_windows-fastbuild/bin/service_proto-descriptor-set.proto.bin --cpp_out=bazel-out/x64_windows-fastbuild/bin/_rpg_premerge_service_grpc_pb service.proto
# Configuration: b13494da8021d601156ceead4c36029cb968d4e802b5720b6fdcebfd033cee8d
# Execution platform: @local_config_platform//:host
You seem to have passed an empty string as one of the arguments to protoc.exe.  This is actually sort of hard to do.  Congrats.  Unfortunately it is not valid input so the program is going to die now.
Target //:service_grpc failed to build
INFO: Elapsed time: 259.535s, Critical Path: 15.74s
INFO: 1030 processes: 35 internal, 995 local.
FAILED: Build did NOT complete successfully

rules_proto_grpc Version

4.6.0

Bazel Version

6.4.0

OS

Windows 11

Link to Demo Repo

https://github.com/emilbon99/proto_rules_grpc_b_1

MODULE.bazel or WORKSPACE Content

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

http_archive(
    name = "rules_proto_grpc",
    sha256 = "2a0860a336ae836b54671cbbe0710eec17c64ef70c4c5a88ccfd47ea6e3739bd",
    strip_prefix = "rules_proto_grpc-4.6.0",
    urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/releases/download/4.6.0/rules_proto_grpc-4.6.0.tar.gz"],
)

load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains")
rules_proto_grpc_toolchains()
rules_proto_grpc_repos()

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()

load("@rules_proto_grpc//cpp:repositories.bzl", "cpp_repos")
cpp_repos()

load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()

load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
grpc_extra_deps()

BUILD Content

load("@rules_proto_grpc//cpp:defs.bzl", "cpp_proto_compile")
load("@rules_proto_grpc//cpp:defs.bzl", "cpp_grpc_library")
load("@rules_proto_grpc//cpp:defs.bzl", "cpp_grpc_compile")

proto_library(
    name = "service_proto",
    srcs = ["service.proto"],
    visibility = ["//visibility:public"],
)

cpp_proto_compile(
    name = "service_proto_cc",
    protos = ["service_proto"],
    extra_protoc_files = ["service.proto"],
)

Proto Content

syntax = "proto3";

package test;

service UnaryMessageService {
    rpc Exec(Message) returns (Message) {}
}

service StreamMessageService {
    rpc Exec(stream Message) returns (stream Message) {}
}

message Message
{
    string payload = 1;
}

Any Other Content

See demo repo.
emilbon99 commented 7 months ago

Issue resolved.

For those of you who run into this issue in the future, you need to make sure your bash command in powershell or cmd points to the bash installation from MSYS2. Mine was pointing to bash on WSL.

emilbon99 commented 7 months ago

See above