Skip to content

fix: avoid false Web UI build failures on Windows GBK locales#23850

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-1e3aeebf
May 11, 2026
Merged

fix: avoid false Web UI build failures on Windows GBK locales#23850
teknium1 merged 2 commits into
mainfrom
hermes/hermes-1e3aeebf

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Salvage of #23647 by @VinceZcrikl onto current main.

Summary

hermes update no longer crashes the Web UI build path with UnicodeDecodeError on Windows zh_CN (GBK) locales. The npm subprocesses now decode their captured output as UTF-8 with errors="replace" instead of inheriting the host locale.

Root cause: subprocess.run(text=True) without an explicit encoding falls back to locale.getpreferredencoding(). On Chinese Windows that's GBK, which trips on UTF-8 bytes npm emits — Python raised UnicodeDecodeError and the update flow then printed "Web UI build failed" even though npm run build had succeeded.

Changes

  • hermes_cli/main.py: add encoding="utf-8", errors="replace" to the npm ci, npm install, and npm run build subprocess calls in _run_npm_install_deterministic and _build_web_ui.
  • tests/hermes_cli/test_web_ui_build.py: 2 regression tests asserting the kwargs are present.

Validation

  • scripts/run_tests.sh tests/hermes_cli/test_web_ui_build.py — 13/13 passed.

Closes #23647.

VinceZcrikl and others added 2 commits May 11, 2026 08:05
On Windows systems using a Chinese GBK locale, `hermes update` could misreport the Web UI build as failed even when `npm run build` actually succeeded. The failure was caused by Python decoding captured npm output with the process locale inside a background subprocess reader thread. When npm emitted bytes such as `0x85`, decoding under GBK raised `UnicodeDecodeError`, and Hermes then surfaced a misleading "Web UI build failed" warning.

This change makes the npm install/npm ci path and the Web UI build step decode captured output explicitly as UTF-8 with `errors="replace"`. That keeps unexpected bytes from crashing output collection, preserves successful builds, and prevents false negatives during update on Windows.

The patch also adds regression tests that verify these subprocess calls always use explicit UTF-8 decoding with replacement semantics.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-1e3aeebf vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8118 on HEAD, 8118 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4277 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@teknium1 teknium1 merged commit 88a2ce4 into main May 11, 2026
13 of 16 checks passed
@teknium1 teknium1 deleted the hermes/hermes-1e3aeebf branch May 11, 2026 15:14
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants