bazel-contrib / bazel-contrib/rules_jvm_external

Pinning artifacts on Windows does not work?

Open
#324 2 comments 4 reactions 0 assignees View on GitHub
help wanted os:windows type: bug
Dominant language
Java
Stars
373
Forks
301
Avg merge
7d 17h
Merged PRs (30d)
3

Description

Windows 10
Bazel 1.2.1
rules_jvm_external 3.0 and 2.10 were tried.

I have a small project that uses rules_jvm_external. If I run `bazel build //...` Then everything works fine with just Coursier But when trying to pin the jars by running `bazel run @maven//:pin` I get the following error:

```
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\USER_NAME> cd C:\PROJECT_LOCATION
PS C:\PROJECT_LOCATION> bazel run @maven//:pin
Starting local Bazel server and connecting to it...
INFO: Analyzed target @maven//:pin (1 packages loaded, 1 target configured).
INFO: Found 1 target...
INFO: Deleting stale sandbox base C:/users/USER_NAME/_bazel_USER_NAME/x2wgegak/sandbox
INFO: Elapsed time: 583.469s, Critical Path: 0.04s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
FATAL: ExecuteProgram(C:\users\USER_NAME\_bazel_USER_NAME\x2wgegak\external\maven\pin) failed: ERROR: src/main/native/windows/process.cc(199): CreateProcessW("C:\users\USER_NAME\_bazel_USER_NAME\x2wgegak\external\maven\pin"): %1 is not a valid Win32 application.
(error: 193)
PS C:\PROJECT_LOCATION>
```

If i go look at the pin file that was created, I can see that it is a shell script:

```
#!/usr/bin/env bash

set -euo pipefail
readonly maven_install_json_loc=$BUILD_WORKSPACE_DIRECTORY/maven_install.json
readonly execution_root=$(bazel info execution_root)
readonly workspace_name=$(basename $execution_root)
cat <<"RULES_JVM_EXTERNAL_EOF" | python -m json.tool > $maven_install_json_loc

RULES_JVM_EXTERNAL_EOF

if [ "False" = "True" ]; then
echo "Successfully pinned resolved artifacts for @maven, $maven_install_json_loc is now up-to-date."
else
echo "Successfully pinned resolved artifacts for @maven in $maven_install_json_loc." \
"This file should be checked in your version control system."
echo
echo "Next, please update your WORKSPACE file by adding the maven_install_json attribute" \
"and loading pinned_maven_install from @maven//:defs.bzl".
echo
echo "For example:"
echo
cat <` and then create the file `maven_install.json` and paste the output in. Then if i do a normal bazel build the pined jars are used as expected. So everything works except the creating of the json file.

Thank you,

PS
My apologies if this should have been a stackoverflow question instead of a github issue.

Contributor guide

Open the contributing guide

Research direction

Start with the generated @maven//:pin entry point and inspect the pin file shown in the report, including how it is executed on Windows. Reproduce the CreateProcessW error with Bazel 1.2.1 on Windows 10 and verify that pinning creates maven_install.json without requiring manual copying.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.