Skip to content

🐛 Fix LSP "binary not found" when no workspace folder is open - #106

Merged
nefrob merged 1 commit into
nefrob:mainfrom
brzzdev:fix(lsp)/cwd-no-workspace
Jun 10, 2026
Merged

🐛 Fix LSP "binary not found" when no workspace folder is open#106
nefrob merged 1 commit into
nefrob:mainfrom
brzzdev:fix(lsp)/cwd-no-workspace

Conversation

@brzzdev

@brzzdev brzzdev commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What changed

When a justfile is opened with no workspace folder (a loose file), the Just LSP no longer fails to start with a spurious Just LSP binary not found at path: … warning, even when just-lsp is installed and vscode-just.lspPath is correct.

Why

workspaceRoot() fell back to the literal string "~" when there are no workspace folders. Node does not expand ~, so it was passed as an invalid cwd to the just-lsp --version validation spawn (src/lsp.ts), which threw ENOENT — and the error handler misreported it as the binary being missing, regardless of lspPath. Reproduces exactly:

spawn("/opt/homebrew/bin/just-lsp", ["--version"], { cwd: "~" }) // -> error: ENOENT
spawn("/opt/homebrew/bin/just-lsp", ["--version"], {})           // -> close 0 ✅

The fix returns os.homedir() — the real directory "~" was clearly meant to represent — so the return type stays string and every caller is unaffected.

Things to look out for

workspaceRoot() is also the cwd for the recipe-runner and launcher spawns (src/recipe.ts, src/launcher.ts), so this additionally gives those a valid cwd (instead of "~") when no folder is open.

Related

Closes #104.

workspaceRoot() returned the literal string "~" when no workspace folder
was open. Node does not expand "~", so it was passed as an invalid cwd to
the `just-lsp --version` validation spawn, which threw ENOENT and was
misreported as the LSP binary being missing — even with a correct lspPath.

Use os.homedir() instead.

Fixes #104.

@nefrob nefrob left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Great find! Will get this released later today.

@nefrob
nefrob merged commit 0d3d4be into nefrob:main Jun 10, 2026
1 check passed
@brzzdev
brzzdev deleted the fix(lsp)/cwd-no-workspace branch June 10, 2026 15:17
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.

It notifies "Just LSP binary not found" although the binary is in that path

2 participants