Skip to content

Find sclang on Windows - #186

Merged
ninjudd merged 6 commits into
mainfrom
windows/sclang-lookup
Oct 11, 2026
Merged

ninjudd merged 6 commits into
mainfrom
windows/sclang-lookup

Conversation

@ninjudd

@ninjudd ninjudd commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Since the keyboard instrument's voice host (#179), field finds sclang itself in sclangCommand, and both SuperCollider renders and field keys go through it. On Windows that lookup could not find a real sclang at all, even with SuperCollider installed: its PATH search tried only sclang, never sclang.exe; a native FIELD_SCLANG such as C:\Program Files\SuperCollider-3.13.0\sclang.exe contains no /, so it was searched for as a bare name and reported missing; and the fallback probed only the macOS app bundle. The Windows stack recorded this as an open item in windows-portability.md §7.2.

This makes the lookup platform-aware without changing it on macOS or Linux:

  • On Windows the PATH search tries .com and .exe, and never the bare name, because an extensionless file cannot run there. The rest of PATHEXT is left out on purpose: both callers spawn without a shell, and Node refuses a .bat or .cmd that way (spawn EINVAL, since the CVE-2024-27980 releases). A FIELD_SCLANG that names a batch file is refused with that reason.
  • A FIELD_SCLANG with a backslash, a slash, or a drive is read as a path; a bare name is still searched for on PATH, so a wrapper like sclang-wrapper.exe keeps working.
  • The fallback takes the newest SuperCollider-<version> folder under Program Files, sorting versions numerically so 3.13.0 beats 3.9.3.
  • PATH and ProgramFiles are read without regard to case. Windows usually spells the first one Path, and the voice host can pass a copied environment, which loses the case-insensitive lookup that only process.env has.

The platform is a parameter of sclangCommand, defaulting to process.platform, so src/generators/supercollider.test.ts exercises each Windows rule against real files on any machine; the two tests whose fixtures only a POSIX host can hold skip on Windows. build.test.ts now probes for a real sclang with the same lookup, so its integration test runs on Windows when SuperCollider is installed. docs/cli.md and docs/keys.md describe the whole lookup order, and the plan records the item as ported. #185 also edits docs/cli.md, in different lines (its FIELD_OFFLINE row and the Platform notes), so whichever merges second should merge cleanly.

Testing

From the root of a checkout of windows/sclang-lookup, with the daemon built by pnpm build:native (the full suite's daemon tests need it):

pnpm install --frozen-lockfile
pnpm typecheck
pnpm exec vitest run src/generators/supercollider.test.ts
pnpm test
project check

You should see a clean typecheck, Tests 11 passed (11) for the lookup tests, the full suite passing (995 passed and 1 skipped on macOS here), and Project plans are valid. The lookup tests are what would show the change wrong: a failure in any test whose name mentions Windows means sclang.exe, a native FIELD_SCLANG, or the Program Files fallback is not found. Against main's lookup, every Windows test fails.

Nothing here can be exercised by hand on macOS. The windows CI job runs the same tests natively on Windows. A by-hand check on a Windows machine with SuperCollider installed is field keys or field build on a project with a supercollider: entry, which should find sclang.exe with no FIELD_SCLANG set. The commands leave the checkout unchanged.

📽️ Projector summary of d1169c1: https://field.amnes.ac/reviews/186

sclangCommand, which SuperCollider renders and the field keys voice host
share since #179, could not find a real sclang on Windows: its PATH
search tried only `sclang`, a native FIELD_SCLANG such as
C:\Program Files\SuperCollider-3.13.0\sclang.exe has no slash and was
searched for as a name, and the fallback probed only the macOS app
bundle.

On Windows the PATH search now tries each PATHEXT extension and never a
bare name, a FIELD_SCLANG with a backslash, slash, or drive is a path,
and the fallback takes the newest SuperCollider-<version> under Program
Files. PATH, PATHEXT, and ProgramFiles are read without regard to case,
because a copied environment loses Windows' case-insensitive lookup.
macOS and Linux behave as before.

The platform is a parameter, so supercollider.test.ts runs every rule on
any machine. Each of its Windows tests fails against the old lookup.
docs/cli.md and docs/keys.md named PATH and the macOS app bundle only. They now give the whole order, with sclang.exe on PATH and the Program Files fallback, and windows-portability.md §7.2 records the item as ported.

@ninjudd ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📽️ Projector review · 0.7.4 · model claude-opus-5-5 · effort xhigh · CHANGES REQUESTED · took 20m 51s

This pull request makes sclangCommand find sclang on Windows. That is the lookup that SuperCollider renders and the field keys voice host share, and the change leaves it as it was on macOS and Linux. On Windows the lookup searches PATH with each PATHEXT extension, and it reads a FIELD_SCLANG that holds a backslash, slash, or drive as a path. It then falls back to the newest SuperCollider-<version> folder under Program Files, and it reads PATH, PATHEXT, and ProgramFiles without regard to case. The platform becomes a parameter so that the new tests run the Windows rules on any machine, and docs/cli.md, docs/keys.md, and the plan's §7.2 entry record the new order. The pull request does not claim to fix the voice-host tests that fail on main's Windows job.

2 finding threads: 0 resolved, 2 open

Covered 6 of 6 changed files; none are generated.

Disclosure. I reviewed on macOS and could not run anything on Windows. I ran the Windows rules through the built sclangCommand with platform set to win32 against temporary files, and read the Windows-only branches against Node's documented spawn behavior. The pull request's own windows CI job is the only native Windows run, and its result is under "What I ran".

What I ran

  • Install and typecheck. pnpm install --frozen-lockfile and pnpm typecheck in a worktree at 603c3e1 are clean.
  • The lookup and voice-host tests. pnpm exec vitest run src/generators/supercollider.test.ts src/keys/voice-host.test.ts passes 22 of 22 on macOS.
  • The SuperCollider parts of the build tests. pnpm exec vitest run src/graph/build.test.ts -t "^(supercollider|runScProgram edges)" passes 7 and skips the other 27. I left out the real-sclang integration test on purpose.
  • Plans. project check prints Project plans are valid.
  • Edge cases, against the built sclangCommand. On linux and darwin the results match main: a FIELD_SCLANG with / is a path, a bare name is searched on a :-split PATH, and only macOS falls back to the app bundle. The one difference is that Linux no longer checks /Applications/SuperCollider.app/…, which cannot exist there. On win32, SuperCollider-3.10 sorts above SuperCollider-3.9, and 3.13.0 sorts above both. A newest folder with no sclang.exe in it is skipped. The keys Path, PathExt, and programfiles are found, a lowercase PATHEXT of .exe;.cmd works, and a native FIELD_SCLANG that names a missing file reports FIELD_SCLANG points at a missing binary. ProgramW6432 is not read. That is fine, because Node publishes no 32-bit Windows build from version 23 on, so ProgramFiles already names the 64-bit folder for field's process.
  • CI. The linux job passes. The windows job fails 13 tests, and main's run at 6a62817 failed 12. Two of the 13 are new lookup tests, filed as a thread. The other 11 also fail on main: the two MIDI daemon tests, the three resolving an instrument tests, which compare POSIX paths, and the six the voice host process tests. Those six now get past the lookup, which on main rejected the stub's native path with FIELD_SCLANG points at a missing binary. They fail at spawn instead, with could not start sclang: spawn …\sclang ENOENT, because the stub is an extensionless Node script that Windows cannot start, and two of them now run 5 seconds before they fail. main's twelfth failure, an inventory cache test in src/audio/plugin-hosting.test.ts, passed in this run.

Suggestions

  • src/graph/build.test.ts:581: sclangPresent repeats the old POSIX lookup, which checks the app bundle or sclang on a :-split PATH. So the real-sclang integration test still skips on a Windows machine with SuperCollider installed. Probe with sclangCommand() in a try, as src/keys/voicer.test.ts:13 does, and it runs there too.

Comment thread src/generators/supercollider.ts Resolved
Comment thread src/generators/supercollider.test.ts Resolved
onPath tried every PATHEXT extension, so a sclang.cmd on PATH shadowed the installed sclang.exe and FIELD_SCLANG=sclang-wrapper resolved to sclang-wrapper.cmd. Both callers spawn without a shell, and Node refuses .bat and .cmd there with spawn EINVAL since the CVE-2024-27980 releases, so a render failed with a bare EINVAL where main had reported the missing binary.

The Windows search now tries .com and .exe only, and a FIELD_SCLANG that names a batch file is refused with the reason. The wrapper test uses an .exe; two new tests cover a .cmd on PATH being passed over and a batch FIELD_SCLANG being refused, and the plan's note says the same.
On the windows CI job, the macOS/Linux PATH test split a Windows temp path at its drive colon, and the native-FIELD_SCLANG test could not create a directory named C:. Both fixtures need a POSIX host; the linux job still runs them.
sclangPresent repeated the old POSIX lookup, so the sc-render integration test skipped on a Windows machine with SuperCollider installed. It now asks the lookup the renders use, as voicer.test.ts does.

@ninjudd ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📽️ Projector review · 0.7.4 · model claude-opus-5-5 · effort xhigh · CLEAN · took 17m 23s

This pull request makes sclangCommand find sclang on Windows. That is the lookup that SuperCollider renders and the field keys voice host share, and the change leaves it as it was on macOS and Linux. On Windows the lookup searches PATH for sclang.com and sclang.exe, the only extensions Node can start without a shell, and it reads a FIELD_SCLANG that holds a backslash, slash, or drive as a path. A FIELD_SCLANG that names anything else, such as a .cmd wrapper, is refused with the reason. The lookup then falls back to the newest SuperCollider-<version> folder under Program Files, and it reads PATH and ProgramFiles without regard to case. The platform becomes a parameter so that the new tests run the Windows rules on any machine. build.test.ts now probes for a real sclang with the same lookup, and docs/cli.md, docs/keys.md, and the plan's §7.2 entry record the new order. The pull request does not claim to fix the voice-host tests that fail on main's Windows job.

2 finding threads: 2 resolved, 0 open

Covered 6 of 6 changed files; none are generated.

Disclosure. I reviewed on macOS and could not run anything on Windows. I ran the Windows rules through the built sclangCommand with platform set to win32 against temporary files. The pull request's own windows CI job is the only native Windows run, and its result is below.

Suggestions

  • src/generators/supercollider.ts:151: the refusal says which Windows will not start without a shell, which fits a .bat or .cmd but not an extensionless file, the case the voice-host stub hits on the windows job. Wording such as which Windows cannot start directly would cover both.

Earlier findings, checked at b2f19a0

  • The lookup returned .cmd and .bat scripts that field cannot start. Fixed. onPath now tries only WINDOWS_EXECUTABLES, which are .com and .exe, and sclangCommand refuses a Windows FIELD_SCLANG with any other extension before anything is spawned. In my probe, a sclang.cmd and a sclang.bat earlier on PATH are passed over for sclang.exe. A bare FIELD_SCLANG with only a .cmd beside it reports missing binary. A .cmd or .BAT named by path or by name reports which Windows will not start without a shell.
  • Two new tests failed on the Windows CI job. Fixed. Both run through it.skipIf(process.platform === 'win32'), and the linux job still runs them. On the windows job, supercollider.test.ts runs 8 tests and skips those 2, and all 8 pass.

What I checked

  • macOS and Linux keep their lookup. With platform set to linux or darwin, the built sclangCommand returns what main returns. A FIELD_SCLANG with / is a path, even one ending in .cmd, and a bare name is searched on a :-split PATH. Only macOS falls back to the app bundle.
  • The Windows rules. PATHEXT no longer changes the result, empty or not. sclang.com is found, and an uppercase .EXE passes the extension check. SuperCollider-3.13.0 sorts above 3.10 and 3.9, and a newest folder with no sclang.exe in it is skipped. The keys Path and programfiles are found, and a missing native FIELD_SCLANG reports missing binary.
  • Install, typecheck, and plans. pnpm install --frozen-lockfile and pnpm typecheck are clean, and project check prints Project plans are valid.
  • Focused tests on macOS. pnpm exec vitest run src/generators/supercollider.test.ts src/keys/voice-host.test.ts passes 24 of 24. pnpm exec vitest run src/graph/build.test.ts -t "^(supercollider|runScProgram edges)" passes 7 and skips 27, and I left out the real-sclang integration test on purpose.
  • The callers. runScProgram and VoiceHost.start still start the result without a shell, so every path the lookup can return on Windows ends in .com or .exe. The sclangPresent probe in build.test.ts runs once, when the file loads, before any test sets FIELD_SCLANG.
  • CI. The linux job passes. The windows job fails 13 tests, and none of them is in a file this pull request changes. Eleven fail on every recent Windows run, main included: the two MIDI daemon tests, the three resolving an instrument tests, which compare POSIX paths, and the six the voice host process tests. Those six now stop at the lookup, because their stub is an extensionless Node script, and the new refusal names it: FIELD_SCLANG points at …\sclang, which Windows will not start without a shell. The other two vary between runs. inventory cache in src/audio/plugin-hosting.test.ts also failed on main at 6a62817. punch-out and loop takes > a loop take lands one take per pass in src/commands/punch-daemon.test.ts timed out waiting for the daemon, and it passed on the ui/review-followups run at the same time. Neither one reaches sclangCommand.

@ninjudd
ninjudd marked this pull request as ready for review October 11, 2026 05:43
@ninjudd
ninjudd marked this pull request as draft October 11, 2026 05:44
"which Windows will not start without a shell" fits a .bat or .cmd, but the voice-host test stub on the windows job is an extensionless file, which Windows cannot start either. "which Windows cannot start directly" reads true for both, and a new test covers the extensionless case.

@ninjudd ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📽️ Projector review · 0.7.4 · model claude-opus-5-5 · effort xhigh · CLEAN · incremental from b2f19a0 · took 0m 57s

Incremental review of the change since the full review of b2f19a0: +11 −2 lines in 2 files.

The refusal for a Windows FIELD_SCLANG that is not a .com or .exe now reads which Windows cannot start directly, which is true for an extensionless file as well as a .cmd or .bat. A new test covers the extensionless case with a fixture a Windows host can hold. I searched src, docs, sc, and scripts for the old wording and found no other reader. At this head pnpm typecheck is clean, and the lookup and voice-host tests pass 25 of 25 on macOS.

@ninjudd
ninjudd marked this pull request as ready for review October 11, 2026 05:47
ninjudd added a commit that referenced this pull request Oct 11, 2026
Justin's #186 fixes sclangCommand on Windows, opened before this, with its own rules (.com and .exe, never the bare name). This pull request now carries only the homeRelative fix, so the two do not collide.
@ninjudd
ninjudd merged commit 6010446 into main Oct 11, 2026
1 of 2 checks passed
@ninjudd
ninjudd deleted the windows/sclang-lookup branch October 11, 2026 15:07
ninjudd added a commit that referenced this pull request Oct 11, 2026
…192)

`field export` prints where each file landed with your home folder
shortened to `~`, but `homeRelative` looked for the home path followed
by `/`. On Windows the separator is `\`, so no path ever matched, and
every export printed its full `C:\Users\…` path. The Windows portability
sweep listed this as a standalone item in `windows-portability.md` §7.2.

`homeRelative` now takes the platform's separator, defaulting to
`path.sep`, so a Windows path under the profile prints as `~\Desktop\…`.
Windows paths compare without regard to case, as Windows itself does, so
`--to c:\users\me\Music` shortens like `C:\Users\me\Music`; only the
prefix of the home path's length is compared, so the rest is sliced at
the same place, and it prints as you gave it. The rule that a sibling
folder such as `C:\Users\justinx` is not home still holds. On macOS and
Linux the separator is `/` and the comparison keeps case, as before. The
OneDrive-redirected Desktop, the other half of that item, stays the
cosmetic wart the plan calls it: the export still lands there and prints
its path.

The same §7.2 item for finding `sclang` on Windows was here too at
first, and I took it out. Justin's #186, opened earlier, fixes it with
stricter rules, so this pull request no longer touches `sclangCommand`
and the two do not collide. The plan's note on the `homeRelative` item
is the only edit here to `windows-portability.md`.

## Testing

From the repository root of this branch, after `pnpm install`:

```sh
pnpm typecheck
pnpm exec vitest run src/commands/export.test.ts src/graph/build.test.ts
FIELD_AUDIOD=$PWD/native/audiod/build/field-audiod_artefacts/Release/field-audiod pnpm test
project check
git diff --stat origin/main
```

The typecheck passes, the two files pass 64 of 64, and the full suite
passes 984 with 1 skipped. `project check` prints `Project plans are
valid.`, and the diff against `main` touches only
`src/commands/export.ts`, `src/commands/export.test.ts`, and
`docs/projects/windows-portability/readme.md`. Every case in
`export.test.ts` names its separator, so the test means the same on the
Windows CI job as here. With `\`,
`C:\Users\justin\Desktop\creek-mix-main-v1.wav` comes back as
`~\Desktop\creek-mix-main-v1.wav`, `c:\users\justin\Music` as `~\Music`,
and `C:\Users\justinx\Desktop` unchanged. With `/`,
`/users/justin/Desktop` stays as it is under the home `/Users/justin`.
If any comes back otherwise, the change is wrong.

On a Windows machine, `field export` in a project should now print its
destination as `~\Desktop\…`. No Windows machine has run it; the unit
test is what covers it until one does. Nothing is left behind.

<!-- projector-summary v=1 sha=f9ea793b7ce6077192b9b5a1b6db6c92bae75d16
-->
📽️ **Projector summary** of f9ea793: https://field.amnes.ac/reviews/192
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant