[Bug] Language servers installed with npm are reported as available but never start on Windows
Description
On Windows, npm installs language servers (typescript-language-server, pyright, vscode-*-language-server) as .cmd shims. Nanocoder finds them with where (which understands .cmd) and reports them as available. But it then checks and starts them with execFileSync and spawn without a shell, and those cannot run a .cmd file. So no server starts and LSP features stay off. Only servers that ship as real .exe files (like gopls, rust-analyzer, clangd) should work.
Environment
- OS: Windows 11 (10.0.26300)
- Node version: 22.22.3
- Nanocoder version: 1.31.0 (main at 6eaff7af)
- typescript-language-server: 6.0.2, installed with
npm install typescript-language-server typescript - Provider / Model: not relevant
Steps to Reproduce
- On Windows, run
npm install typescript-language-server typescriptand putnode_modules\.binonPATH. - Make a project with
tsconfig.jsonanda.ts. - In that folder, call
getKnownServersStatus()anddiscoverLanguageServers()fromsource/lsp/server-discovery.ts. - Compare with
cmd /c typescript-language-server --versionand withspawn('typescript-language-server', ['--stdio']).
Expected Behavior
The server is discovered and started, like it is on Linux and macOS.
Actual Behavior
where typescript-language-server -> node_modules/.bin/typescript-language-server | .../typescript-language-server.cmd
cmd /c typescript-language-server --version -> 6.0.2 (Windows can run it)
execFileSync('typescript-language-server', ...) -> FAILS: ENOENT
getKnownServersStatus() ... {"name":"typescript-language-server","available":true}
discoverLanguageServers() []
spawn('typescript-language-server', ['--stdio']) -> error event: ENOENT
Suggested Fix
source/lsp/server-discovery.ts:findCommand(about lines 249-266) useswhere, so it succeeds.verifyServer(about lines 274-290,execFileSync) andverifyLSPServerWithCommunication(about line 302,spawn) cannot run the shim.source/lsp/lsp-client.ts:69has the samespawn.- Use
cross-spawnfor all three. I checked thatcross-spawn.sync('typescript-language-server', ['--version'])returns6.0.2here. Note thatcross-spawnis only a transitive dependency today and is not imported anywhere in the repo, so add it topackage.json(and keepkniphappy). - Or resolve
<name>.cmdand run it throughcmd.exe /d /s /conwin32. Thenode_modules/.binfallback infindCommandfinds the extensionless POSIX shim, which also can't be spawned on Windows. - Add a Windows-only test: put a fake
typescript-language-server.cmdonPATHand expectdiscoverLanguageServers()to return it. That exact test fails today.
Additional Context
- Related but different: #1516 (
file://URI parsing on Windows), #605 (closed, debug log noise). - [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder
hey @addyCooks can i get assigned for this issue?
Assigned to you, @Srinidhi444! Quick heads-up for next time: please include a brief implementation plan when requesting an issue assignment It helps us understand your approach beforehand : )
7. Assigned to you, @Srinidhi444! Quick heads-up for next time: please include a brief implementation plan when requesting an issue assignment It helps us understand your approach beforehand : )
sure will keep that in mind
Hey @addyCooks, I’ve implemented a fix locally using the cross-spawn approach suggested in the issue.
The changes:
- Add
cross-spawnas a direct dependency and use it for version verification, discovery’s spawn check, and actual LSP startup. - Update the local
node_modules/.binfallback to select.exe,.cmd, or.batfiles on Windows. - Pass the resolved command path and arguments separately so paths containing spaces work correctly.
- Check synchronous launch errors and exit status so failed version checks aren’t accepted.
I’ve also added six Windows regression tests covering discovery, local shims, paths with spaces, failed verification, and LSP initialization/shutdown. All six tests, type checks, and formatting checks pass locally.
The implementation and targeted tests are ready. Does this approach sound good? If so, I’ll finish the full repository checks, add the patch changeset, and open a PR.
Thanks @Srinidhi444, that approach sounds good, please open the PR. A few notes so CI passes first time:
- Switch the version check and communication check in
server-discovery.ts, and the spawn inlsp-client.ts. Keep the existingnosemgrepcomment. cross-spawnis already in the lockfile, so add it as a direct dependency, plus@types/cross-spawnas a dev dependency.pnpm test:knipshould pass.- CI only runs two specs on Windows, so put your Windows tests in their own spec file, skip them off Windows, and add that file to the "Custom Tools (Windows)" job in
pr-checks.yml. - Add a patch changeset, fill in the PR template, and mention me for review.
hey @addyCooks have raised pr please check and let me know if any issues comes up . thanks!