stablyai / stablyai/orca

[Bug]: pnpm install fails on Windows when the user profile name is non-ASCII — node-gyp writes binding.sln without a BOM

Open
#18,052 2 comments 0 reactions 1 assignee Claimed by @nwparker View on GitHub
os:Windows
Dominant language
TypeScript
Stars
71.3k
Forks
4.7k
Avg merge
17h 8m
Merged PRs (30d)
475

Description

### Operating system

Windows

### Orca version

1.4.194 (`main` @ f088872554)

### Details

`pnpm install` cannot finish on a Windows machine whose user profile name contains non-ASCII characters. The postinstall native rebuild fails every time:

```
[rebuild] Patched node-pty build artifacts are missing; rebuilding from source.
...\node-pty\build\binding.sln(12): solution file error MSB5013: An error occurred while parsing the project section.
Error: MSBuild.exe failed with exit code: 1
[rebuild] Native module rebuild failed: node-gyp failed to rebuild '...node-pty'
```

### Root cause

node-gyp resolves `node-addon-api` through pnpm's store with a relative path that walks up out of the package:

```
"..\..\..\..\node-addon-api@7.1.1\node_modules\node-addon-api\node_addon_api_except.vcxproj"
```

and emits a solution-folder node for every segment of that walk. On this machine that includes the user profile directory, so `binding.sln` line 12 is:

```
Project("{2150E333-...}") = "()", "..\Users\", "{917AF3A5-...}"
```

The file is written as UTF-8 **without a BOM**. MSBuild falls back to the system ANSI code page (949 here) when a solution file has no BOM, so those bytes decode to mojibake and the project section fails to parse.

Nothing about the module is wrong — it is purely the generated solution file being unreadable in the active code page.

### Confirmed fix and workaround

Splitting the rebuild and adding the BOM between the two phases builds cleanly:

```bash
cd node_modules/.pnpm/node-pty@1.1.0_patch_hash=*/node_modules/node-pty
npx node-gyp configure
python -c "import io;p='build/binding.sln';r=io.open(p,'rb').read();io.open(p,'wb').write(b'\xef\xbb\xbf'+r)"
npx node-gyp build # -> build/Release/conpty.node
```

That produces the artifact, so **the missing BOM is the whole problem**.

The workaround does not survive, though: `pnpm install` / `pnpm build` re-enter `rebuild-native-deps.mjs`, and `node-gyp rebuild` cleans before it configures, so the patched solution file and the built `.node` are both discarded and the next run fails the same way.

### Why I did not open a PR

`config/scripts/rebuild-native-deps.mjs` delegates the whole build to `@electron/rebuild`:

```js
await rebuild({ ... }) // the only build invocation in the script
```

which calls `node-gyp rebuild` (clean → configure → build) internally. There is no seam between configure and build to insert the BOM, and pre-writing the file does not help because the clean step removes it. A real fix looks like it belongs in node-gyp — write the solution file with a BOM, or ASCII-escape the generated folder names — rather than in this repo.

Filing it here because it blocks `pnpm install` outright for anyone in this situation, and the two encoding failures are not obvious from the error text alone — the diagnosis may save the next person the search.

### Repro

1. On Windows, use a user profile whose name contains non-ASCII characters (Korean here; any CP-non-representable name should do).
2. Clone the repo under that profile and run `pnpm install`.
3. postinstall fails with `MSB5013` on `binding.sln`.

### Environment

Windows 11 (10.0.26200), system code page 949, Node 24, VS 2022 Build Tools, pnpm workspace install.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.