aspect-build / aspect-build/rules_ts

[Bug]: `ts_project` validation and compilation fails on Windows for paths with special characters

Open
#666 5 comments 0 reactions 0 assignees View on GitHub
bug can close? need: more info need: repro
Dominant language
Starlark
Stars
138
Forks
87
Avg merge
2d 8h
Merged PRs (30d)
3

Description

### What happened?

When building a library ts_project within a Next.js app that has special characters (e.g. for route grouping), the ts_project validation fails with a bash syntax error from the unescaped special characters in the file path (in my case `(marketing)`

```
ERROR: C:/users/willschmitt/documents/achillea/achillea/www/achillearesearch_com/app/(marketing)/BUILD.bazel:3:11: TsValidateOptions www/achillearesearch_com/app/(marketing)/(marketing).optionsvalid.d.ts failed: (Exit 2): validator.bat failed: error executing TsValidateOptions command (from target //www/achillearesearch_com/app/(marketing):(marketing))
cd /d C:/_bzl/execroot/_main
SET BAZEL_BINDIR=bazel-out/x64_windows-fastbuild/bin
bazel-out\x64_windows-opt-exec-ST-13d3ddad9198\bin\external\aspect_rules_ts~~ext~npm_typescript\validator.bat www/achillearesearch_com/app/(marketing)/tsconfig_(marketing).json www/achillearesearch_com/app/(marketing)/(marketing).optionsvalid.d.ts @@//www/achillearesearch_com/app/(marketing):(marketing) www/achillearesearch_com/app/(marketing) {"allow_js":false,"composite":true,"declaration":true,"declaration_map":false,"emit_declaration_only":false,"incremental":true,"preserve_jsx":false,"resolve_json_module":true,"source_map":false,"ts_build_info_file":""}
# Configuration: 21d0e975c9b4032915c05f5c2f059dd025b6cc6feb8901ed4ba494dc16c40af5
# Execution platform: @@local_config_platform//:host
'DOSKEY' is not recognized as an internal or external command,
operable program or batch file.
/usr/bin/bash: -c: line 1: syntax error near unexpected token `('
/usr/bin/bash: -c: line 1: `C:/_bzl/execroot/_main/bazel-out/x64_windows-opt-exec-ST-13d3ddad9198/bin/external/aspect_rules_ts~~ext~npm_typescript/validator.sh www/achillearesearch_com/app/(marketing)/tsconfig_(marketing).json www/achillearesearch_com/app/(marketing)/(marketing).optionsvalid.d.ts @@//www/achillearesearch_com/app/(marketing):(marketing) www/achillearesearch_com/app/(marketing) "{\\"allow_js\\":false,\\"composite\\":true,\\"declaration\\":true,\\"declaration_map\\":false,\\"emit_declaration_only\\":false,\\"incremental\\":true,\\"preserve_jsx\\":false,\\"resolve_json_module\\":true,\\"source_map\\":false,\\"ts_build_info_file\\":\\"\\"}"'
```

### Version

Development (host) and target OS/architectures: Windows 10 64bit

Output of `bazel --version`: 7.1.1

Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file:
* aspect_rules_ts - 2.4.2
* aspect_bazel_lib - 2.7.9 (upgraded after having other path escaping issues from file copying in earlier v1.x releases)

Language(s) and/or frameworks involved: Typescript and Next.js

### How to reproduce

```shell
Build a `ts_project` within a Bazel package with parentheses in the path on Windows with `validate` set to `True`
```

### Any other information?

For now, I'm disabling validation on ts_project targets under directories with special characters on Windows with a select statement, and getting coverage of validation via Linux CI, but it would be better to have immediate feedback during development:
```starlark
ts_project(
...
validate = select({
"@platforms//os:windows": False,
"//conditions:default": True,
}),
)
```

I also started with a similar issue of unrecognized programs when I was on v1 of the Aspect bazel-lib, but the rules since moved from .bat execution to coreutils execution of CopyFile. I wonder if there is a generalized issue for path normalization on Windows for the bazel-lib

Contributor guide

Open the contributing guide

Research direction

Start at the ts_project validation entry point and compare the validator.bat and validator.sh invocations shown in the report, focusing on paths containing parentheses on Windows. Reproduce the build with validate=True, then confirm that the same target validates and compiles successfully without shell syntax errors when special characters are present.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, typescript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.