aspect-build / aspect-build/rules_js
js_image_layer fails on windows
- Dominant language
- Starlark
- Stars
- 378
- Forks
- 183
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 32
Description
js_image_layer is failing on windows due to a mixture of forward and backslashes in the mtree file
Example:
```
npm_link_all_packages(name = "node_modules")
js_library(
name = "mgr-lib",
srcs = glob([
"lib/**/*.js",
]),
data = [
":node_modules/colors",
]
)
js_binary(
name = "mgr",
entry_point = "x",
data = [
":mgr-lib",
],
patch_node_fs = False,
preserve_symlinks_main = False,
)
js_image_layer(
name = "layers",
binary = ":mgr",
root = "/app",
)
```
Results in:
```
>bazel build ... --verbose_failures
ERROR: D:/workdir/redacted/src/mgr/BUILD.bazel:126:15: JsImageLayer package_store_3p //src/mgr:layers failed: (Exit 1): tar.exe failed: error executing JsImageLayer command (from target //src/mgr:layers)
cd /d D:/redacted/b/buusiixg/execroot/_main
SET LC_ALL=C.UTF-8
external\aspect_bazel_lib~~toolchains~bsd_tar_windows_amd64\tar.exe --create --file bazel-out/x64_windows-opt/bin/src/mgr/layers_package_store_3p.tar.gz --gzip --options=gzip:!timestamp @bazel-out/x64_windows-opt/bin/src/mgr/layers_package_store_3p.mtree
tar.exe: Error reading archive bazel-out/x64_windows-opt/bin/src/node-mgr/layers_package_store_3p.mtree: Can't open bazel-out/x64_windows-opt/bin/node_modules/.aspect_rules_js/@colors+colors@1.6.0/node_modules/@colors/colors/examples
ormal-usage.js
tar.exe: Error exit delayed from previous errors.
```
Mtree:
```
#mtree
./app uid=0 gid=0 time=0 mode=0755 type=dir
./app/src/mgr/node-mgr.runfiles/_main/node_modules/.aspect_rules_js/@colors+colors@1.6.0/node_modules/@colors/colors/LICENSE uid=0 gid=0 time=0 mode=0555 type=file content=bazel-out/x64_windows-opt/bin/node_modules/.aspect_rules_js/@colors+colors@1.6.0/node_modules/@colors/colors/LICENSE
./app/src/mgr/node-mgr.runfiles/_main/node_modules/.aspect_rules_js/@colors+colors@1.6.0/node_modules/@colors/colors/README.md uid=0 gid=0 time=0 mode=0555 type=file content=bazel-out/x64_windows-opt/bin/node_modules/.aspect_rules_js/@colors+colors@1.6.0/node_modules/@colors/colors/README.md
./app/src/mgr/node-mgr.runfiles/_main/node_modules/.aspect_rules_js/@colors+colors@1.6.0/node_modules/@colors/colors/examples\normal-usage.js uid=0 gid=0 time=0 mode=0555 type=file content=bazel-out/x64_windows-opt/bin/node_modules/.aspect_rules_js/@colors+colors@1.6.0/node_modules/@colors/colors/examples\normal-usage.js
./app/src/mgr/node-mgr.runfiles/_main/node_modules/.aspect_rules_js/@colors+colors@1.6.0/node_modules/@colors/colors/examples\safe-string.js uid=0 gid=0 time=0 mode=0555 type=file content=bazel-out/x64_windows-opt/bin/node_modules/.aspect_rules_js/@colors+colors@1.6.0/node_modules/@colors/colors/examples\safe-string.js
./app/src/mgr/node-mgr.runfiles/_main/node_modules/.aspect_rules_js/@colors+colors@1.6.0/node_modules/@colors/colors/index.d.ts uid=0 gid=0 time=0 mode=0555 type=file content=bazel-out/x64_windows-opt/bin/node_modules/.aspect_rules_js/@colors+colors@1.6.0/node_modules/@colors/colors/index.d.ts
```
I believe the issue may be this code:
https://github.com/aspect-build/rules_js/blob/78f20055ac2c09792e5b0bb0cddc12f9dac2388d/js/private/js_image_layer.bzl#L494
I suspect tree_relative_path returns backslashes when running on windows and these need to be mapped to forward slashes before passing to bsdtar
Contributor guide
Research direction
Start in js/private/js_image_layer.bzl around line 494 and inspect how tree_relative_path values are written into the mtree file. Reproduce the provided Windows Bazel build, then verify that generated paths use forward slashes so bsdtar can read the archive successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100