Skip to content

fix(tui): resolve esbuild binary path in build.mjs to avoid version m…#27263

Open
jimmyjonezz wants to merge 1 commit into
NousResearch:mainfrom
jimmyjonezz:fix/tui-esbuild-arm64-version-mismatch
Open

fix(tui): resolve esbuild binary path in build.mjs to avoid version m…#27263
jimmyjonezz wants to merge 1 commit into
NousResearch:mainfrom
jimmyjonezz:fix/tui-esbuild-arm64-version-mismatch

Conversation

@jimmyjonezz

@jimmyjonezz jimmyjonezz commented May 17, 2026

Copy link
Copy Markdown

Resolve esbuild binary path in build.mjs to avoid version mismatch on Android arm64

On Android arm64 (Termux), the @esbuild/android-arm64 binary installed in node_modules can end up with a different version than the esbuild package's lib/main.js expects. For example, npm may install esbuild@0.27.7 as the JS package while pulling @esbuild/android-arm64@0.28.0 as a dependency of a transitive package (tsx). When esbuild's lib/main.js tries to start a service subprocess, it reads the binary version from the spawned process's first packet and compares it against the hardcoded host version, throwing:

Cannot start service: Host version "0.27.7" does not match binary version "0.28.0"

Root cause: ESBUILD_BINARY_PATH is read from environment and overrides the local binary. On this system, ~/.hermes/esbuild-built exists (0.28.0) from a previous installation and pollutes the build. Additionally, require.resolve('@esbuild/android-arm64') in generateBinPath() can find the wrong copy when multiple versions exist in the dependency tree (e.g. node_modules/tsx/node_modules/@esbuild/android-arm64).

Previously attempted fixes (commits b3bd03703 and 5118502c7) tried using the system esbuild at /usr/lib/node_modules/esbuild but that path contains version 0.28.0 which is also incompatible with the 0.27.7 lib/main.js in the project's node_modules.

Fix:

  • Clear ESBUILD_BINARY_PATH env var before loading esbuild (delete process.env.ESBUILD_BINARY_PATH)
  • Import esbuild via createRequire from node:module to use the same require.resolve semantics as generateBinPath()
  • The local esbuild package (esbuild + @esbuild/android-arm64 at matching versions) is already installed at ui-tui/node_modules/esbuild — this ensures the build script uses that pair consistently

Changes:

  • build.mjs: create CJS require via createRequire, delete process.env.ESBUILD_BINARY_PATH, call esbuild.build() instead of bare build() import

…ismatch on Android arm64

On Android arm64 (Termux), the @esbuild/android-arm64 binary installed in
node_modules can end up with a different version than the esbuild package's
lib/main.js expects. For example, npm may install esbuild@0.27.7 as the JS
package while pulling @esbuild/android-arm64@0.28.0 as a dependency of a
transitive package (tsx). When esbuild's lib/main.js tries to start a service
subprocess, it reads the binary version from the spawned process's first
packet and compares it against the hardcoded host version, throwing:

  Cannot start service: Host version "0.27.7" does not match binary version "0.28.0"

Root cause: ESBUILD_BINARY_PATH is read from environment and overrides the
local binary. On this system, ~/.hermes/esbuild-built exists (0.28.0) from a
previous installation and pollutes the build. Additionally,
require.resolve('@esbuild/android-arm64') in generateBinPath() can find the
wrong copy when multiple versions exist in the dependency tree (e.g.
node_modules/tsx/node_modules/@esbuild/android-arm64).

Previously attempted fixes (commits b3bd03703 and 5118502c7) tried using the
system esbuild at /usr/lib/node_modules/esbuild but that path contains version
0.28.0 which is also incompatible with the 0.27.7 lib/main.js in the project's
node_modules.

Fix:
- Clear ESBUILD_BINARY_PATH env var before loading esbuild (delete process.env.ESBUILD_BINARY_PATH)
- Import esbuild via createRequire from node:module to use the same require.resolve semantics as generateBinPath()
- The local esbuild package (esbuild + @esbuild/android-arm64 at matching versions) is already installed at ui-tui/node_modules/esbuild — this ensures the build script uses that pair consistently

Changes:
- build.mjs: create CJS require via createRequire, delete process.env.ESBUILD_BINARY_PATH, call esbuild.build() instead of bare build() import
@cardtest15-coder

This comment was marked as spam.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants