Repository navigation
fix(lsp): run a pinned pyright in the pyright bunx fallback - #146
Conversation
- bunx pyright-langserver requested a nonexistent npm package; run bunx -p pyright@1.1.414 pyright-langserver --stdio instead. - Check for bunx with Bun.which before spawning and drop the dead try/catch. - Pass the current PATH to Bun.which. - Add PyrightServer fallback tests. Closes #137
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request updates the Pyright LSP server implementation to fallback to spawning bunx with a pinned Pyright version (1.1.414) when pyright-langserver is not found on the system PATH. It also adds corresponding unit tests to verify this fallback behavior, path preferences, and error handling when bunx is missing. Feedback on these changes suggests avoiding redundant Bun.which checks before spawning processes, recommending instead to wrap process spawning in a try/catch block to handle missing executables.
There was a problem hiding this comment.
cubic analysis
No issues found across 2 files
Linked issue analysis
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Run the pyright binary from a pinned package | The fallback runs pyright-langserver from pyright@1.1.414 using the exported version constant. |
| ✅ | Return undefined with an install hint when bunx is missing | The server checks for bunx before spawning, logs the install hint, and returns undefined when absent. |
| ✅ | Use the current PATH for both executable lookups | Both pyright-langserver and bunx lookups pass the current process.env.PATH to Bun.which. |
| ✅ | Prefer an installed pyright-langserver over the fallback | The server spawns pyright-langserver directly when found, and the test verifies bunx is bypassed. |
Architecture diagram
sequenceDiagram
participant Client as LSP Client
participant LM as LSPManager
participant PS as PyrightServer (spawn)
participant PN as process.env.PATH
participant BX as bunx CLI
participant npm as npm Registry
Note over Client,PS: Pyright server startup flow
LM->>PS: spawn(root)
alt pyright-langserver found on PATH
PS->>PN: Read current PATH
PS->>PS: Bun.which('pyright-langserver', { PATH })
alt Found
PS->>PS: spawn(pyright, ['--stdio'])
PS-->>LM: process handle
else Not found
Note over PS: Fallback needed
PS->>PS: Bun.which('bunx', { PATH })
alt bunx not found
PS->>PS: Log install hint
PS-->>LM: undefined (broken server)
else bunx found
PS->>BX: spawn(bunx, ['-p', 'pyright@1.1.414', ...])
BX->>npm: Resolve pyright@1.1.414
npm-->>BX: pyright package
BX->>BX: Run pyright-langserver --stdio
BX-->>PS: LSP process
PS-->>LM: process handle
end
end
end
[Medium impact] The PR appears safe to merge. SummaryFixes the Pyright fallback to run
No actionable issues found. Reviews (1) · Last reviewed commit: "fix(lsp): run a pinned pyright in the py..." · Reviewed by Greptile |



Summary
bunx pyright-langserverasks the registry for an npm package namedpyright-langserver, which does not exist (404).pyright-langserveris a bin of thepyrightpackage, so the fallback never worked, and the unclaimed name was a squatting risk (same as #133 for biome). The fallback now runsbunx -p pyright@1.1.414 pyright-langserver --stdio, pinned through an exportedPYRIGHT_VERSION.Bun.which('bunx', { PATH })before spawning. If it is missing, logspyright not found. Install with: npm install pyrightand returnsundefined, so LSPManager marks the server broken instead of waiting out the initialize timeout.'error'event, so it never fired. Spawns the resolved absolute bunx path, asbiome.ts(fix(lsp): run a pinned @biomejs/biome in the biome bunx fallback #134) andtypescript.ts(fix(lsp): check for bunx before the typescript bunx fallback #136) do.Bun.which('pyright-langserver')now passes the current PATH, like the other servers.Out of scope (per the issue notes): a broken mise shim on PATH (
pyright-langserverhas no--versionto probe) and a project-localnode_modules/.binlookup.Related issue
Closes #137
Verification
New
PyrightServer fallbackdescribe inpackages/lsp/test/unit/server.test.ts: the pinned bunx command, preferringpyright-langserveron PATH, andundefinedplus the install hint when bunx is missing.pyright.ts.tsc --noEmitforpackages/lsppasses; eslint is clean.bunx -p pyright@1.1.414 pyright-langserver --stdiostarts "Pyright language server 1.1.414".Checklist
bun run test)bun run lint)BREAKING CHANGE:note is includedSummary by cubic
Fixes the pyright bunx fallback, which never worked because
bunx pyright-langserverrequested a nonexistent npm package (pyright-langserver is a bin of thepyrightpackage) and the unclaimed name was a squatting risk.bunx -p pyright@1.1.414 pyright-langserver --stdio, pinned through the exportedPYRIGHT_VERSION.Bun.whichbefore spawning and removes the dead try/catch, so a missing bunx returnsundefinedand logspyright not found. Install with: npm install pyrightinstead of waiting out the initialize timeout.PATHtoBun.which, matching the biome and typescript servers.PyrightServer fallbacktests covering the pinned command, preferringpyright-langserveronPATH, and the missing-bunx hint.Closes #137.
Written for commit 205a0a8. Summary will update on new commits.