Repository navigation
Find sclang on Windows - #186
Conversation
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
left a comment
There was a problem hiding this comment.
📽️ 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-lockfileandpnpm typecheckin a worktree at603c3e1are clean. - The lookup and voice-host tests.
pnpm exec vitest run src/generators/supercollider.test.ts src/keys/voice-host.test.tspasses 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 checkprintsProject plans are valid. - Edge cases, against the built
sclangCommand. Onlinuxanddarwinthe results matchmain: aFIELD_SCLANGwith/is a path, a bare name is searched on a:-splitPATH, 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. Onwin32,SuperCollider-3.10sorts aboveSuperCollider-3.9, and3.13.0sorts above both. A newest folder with nosclang.exein it is skipped. The keysPath,PathExt, andprogramfilesare found, a lowercasePATHEXTof.exe;.cmdworks, and a nativeFIELD_SCLANGthat names a missing file reportsFIELD_SCLANG points at a missing binary.ProgramW6432is not read. That is fine, because Node publishes no 32-bit Windows build from version 23 on, soProgramFilesalready names the 64-bit folder for field's process. - CI. The
linuxjob passes. Thewindowsjob fails 13 tests, andmain's run at6a62817failed 12. Two of the 13 are new lookup tests, filed as a thread. The other 11 also fail onmain: the two MIDI daemon tests, the threeresolving an instrumenttests, which compare POSIX paths, and the sixthe voice host processtests. Those six now get past the lookup, which onmainrejected the stub's native path withFIELD_SCLANG points at a missing binary. They fail at spawn instead, withcould 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, aninventory cachetest insrc/audio/plugin-hosting.test.ts, passed in this run.
Suggestions
src/graph/build.test.ts:581:sclangPresentrepeats the old POSIX lookup, which checks the app bundle orsclangon a:-splitPATH. So the real-sclang integration test still skips on a Windows machine with SuperCollider installed. Probe withsclangCommand()in atry, assrc/keys/voicer.test.ts:13does, and it runs there too.
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
left a comment
There was a problem hiding this comment.
📽️ 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 sayswhich Windows will not start without a shell, which fits a.bator.cmdbut not an extensionless file, the case the voice-host stub hits on thewindowsjob. Wording such aswhich Windows cannot start directlywould cover both.
Earlier findings, checked at b2f19a0
- The lookup returned
.cmdand.batscripts that field cannot start. Fixed.onPathnow tries onlyWINDOWS_EXECUTABLES, which are.comand.exe, andsclangCommandrefuses a WindowsFIELD_SCLANGwith any other extension before anything is spawned. In my probe, asclang.cmdand asclang.batearlier onPATHare passed over forsclang.exe. A bareFIELD_SCLANGwith only a.cmdbeside it reportsmissing binary. A.cmdor.BATnamed by path or by name reportswhich 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 thelinuxjob still runs them. On thewindowsjob,supercollider.test.tsruns 8 tests and skips those 2, and all 8 pass.
What I checked
- macOS and Linux keep their lookup. With
platformset tolinuxordarwin, the builtsclangCommandreturns whatmainreturns. AFIELD_SCLANGwith/is a path, even one ending in.cmd, and a bare name is searched on a:-splitPATH. Only macOS falls back to the app bundle. - The Windows rules.
PATHEXTno longer changes the result, empty or not.sclang.comis found, and an uppercase.EXEpasses the extension check.SuperCollider-3.13.0sorts above3.10and3.9, and a newest folder with nosclang.exein it is skipped. The keysPathandprogramfilesare found, and a missing nativeFIELD_SCLANGreportsmissing binary. - Install, typecheck, and plans.
pnpm install --frozen-lockfileandpnpm typecheckare clean, andproject checkprintsProject plans are valid. - Focused tests on macOS.
pnpm exec vitest run src/generators/supercollider.test.ts src/keys/voice-host.test.tspasses 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.
runScProgramandVoiceHost.startstill start the result without a shell, so every path the lookup can return on Windows ends in.comor.exe. ThesclangPresentprobe inbuild.test.tsruns once, when the file loads, before any test setsFIELD_SCLANG. - CI. The
linuxjob passes. Thewindowsjob fails 13 tests, and none of them is in a file this pull request changes. Eleven fail on every recent Windows run,mainincluded: the two MIDI daemon tests, the threeresolving an instrumenttests, which compare POSIX paths, and the sixthe voice host processtests. 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 cacheinsrc/audio/plugin-hosting.test.tsalso failed onmainat6a62817.punch-out and loop takes > a loop take lands one take per passinsrc/commands/punch-daemon.test.tstimed out waiting for the daemon, and it passed on theui/review-followupsrun at the same time. Neither one reachessclangCommand.
"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
left a comment
There was a problem hiding this comment.
📽️ 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.
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.
…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
Since the keyboard instrument's voice host (#179), field finds
sclangitself insclangCommand, and both SuperCollider renders andfield keysgo through it. On Windows that lookup could not find a realsclangat all, even with SuperCollider installed: itsPATHsearch tried onlysclang, neversclang.exe; a nativeFIELD_SCLANGsuch asC:\Program Files\SuperCollider-3.13.0\sclang.execontains 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:
PATHsearch tries.comand.exe, and never the bare name, because an extensionless file cannot run there. The rest ofPATHEXTis left out on purpose: both callers spawn without a shell, and Node refuses a.bator.cmdthat way (spawn EINVAL, since the CVE-2024-27980 releases). AFIELD_SCLANGthat names a batch file is refused with that reason.FIELD_SCLANGwith a backslash, a slash, or a drive is read as a path; a bare name is still searched for onPATH, so a wrapper likesclang-wrapper.exekeeps working.SuperCollider-<version>folder under Program Files, sorting versions numerically so 3.13.0 beats 3.9.3.PATHandProgramFilesare read without regard to case. Windows usually spells the first onePath, and the voice host can pass a copied environment, which loses the case-insensitive lookup that onlyprocess.envhas.The platform is a parameter of
sclangCommand, defaulting toprocess.platform, sosrc/generators/supercollider.test.tsexercises 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.tsnow probes for a realsclangwith the same lookup, so its integration test runs on Windows when SuperCollider is installed.docs/cli.mdanddocs/keys.mddescribe the whole lookup order, and the plan records the item as ported. #185 also editsdocs/cli.md, in different lines (itsFIELD_OFFLINErow 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 bypnpm build:native(the full suite's daemon tests need it):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), andProject plans are valid.The lookup tests are what would show the change wrong: a failure in any test whose name mentions Windows meanssclang.exe, a nativeFIELD_SCLANG, or the Program Files fallback is not found. Againstmain's lookup, every Windows test fails.Nothing here can be exercised by hand on macOS. The
windowsCI job runs the same tests natively on Windows. A by-hand check on a Windows machine with SuperCollider installed isfield keysorfield buildon a project with asupercollider:entry, which should findsclang.exewith noFIELD_SCLANGset. The commands leave the checkout unchanged.📽️ Projector summary of d1169c1: https://field.amnes.ac/reviews/186