fix(lsp): resolve highlights.scm via tree-sitter-rsm package root - #84
Merged
Conversation
rsm-lsp crashed at startup in the prod/Docker layout with
"Could not find highlights.scm in any expected location"
(SemanticTokensProvider.loadHighlightQuery). This took the LSP process
down under supervisord and made the Studio backend /health return 503.
Root cause: none of the three search paths resolved in the containerized
node_modules layout.
- The two __dirname-relative paths assume a tree-sitter-rsm checkout
sitting adjacent to the repo root (the dev/monorepo layout). In the
Docker image tree-sitter-rsm is installed under
rsm-lsp/node_modules/tree-sitter-rsm, so neither path exists.
- The require.resolve('tree-sitter-rsm') fallback appended
'../queries/highlights.scm', but tree-sitter-rsm's package.json sets
"main": "bindings/node", so require.resolve returns
.../tree-sitter-rsm/bindings/node/index.js and the join lands on
.../bindings/node/queries/highlights.scm (missing). The queries dir is
at the package root, which needs '../../queries' from the main entry.
Fix: resolve relative to the package root via
dirname(require.resolve('tree-sitter-rsm/package.json')), which is
layout-independent (works whether the package is at the monorepo root in
dev or in node_modules in prod). The __dirname-relative paths remain as
fallbacks.
Verified: tsc builds clean; running the resolution from the compiled
dist/layer1 context finds tree-sitter-rsm/queries/highlights.scm. Full
vitest + live-server runs were not possible on this machine (Node 25
lacks the rollup and tree-sitter native builds); prod builds both in
Docker on linux/node20.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ZfTQx3v4o3aK8V8fi86ot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
rsm-lsp crashes at startup in the prod/Docker layout:
This takes the LSP process down under supervisord and makes the Studio backend
/healthreturn 503 (theservicescheck reportslsp is not running / FATAL Exited too quickly). Core editing and Y.js sync still work; LSP diagnostics/autocomplete do not. Surfaced while verifying the studio prod deploy on 2026-07-02.Root cause
None of
loadHighlightQuery's three search paths resolve in the containerizednode_moduleslayout:__dirname-relative paths assume atree-sitter-rsmcheckout adjacent to the repo root (dev/monorepo layout). In the Docker imagetree-sitter-rsmlives underrsm-lsp/node_modules/tree-sitter-rsm, so neither path exists.require.resolve('tree-sitter-rsm')fallback appended../queries/highlights.scm. Buttree-sitter-rsm/package.jsonsets"main": "bindings/node", sorequire.resolvereturns.../tree-sitter-rsm/bindings/node/index.jsand the join lands on.../bindings/node/queries/highlights.scm(missing). Thequeries/dir is at the package root, which needs../../queriesfrom the main entry, not../queries.This has been broken in the prod layout since semantic tokens were added; the dev path (
../../../../tree-sitter-rsm/...fromsrc/) masked it locally.Fix
Resolve relative to the package root via
dirname(require.resolve('tree-sitter-rsm/package.json')), which is layout-independent (monorepo root in dev,node_modulesin prod). The__dirname-relative paths remain as fallbacks.Verification
tscbuilds clean.dist/layer1context findstree-sitter-rsm/queries/highlights.scm(EXISTS = true).vitest+ live-server runs were not possible on this machine (Node 25 lacks the rollup and tree-sitter native builds); prod builds both in Docker on linux/node20.Rollout
Studio's deploy clones
aris-pub/rsmmain and rebuilds rsm-lsp, so once this merges to rsm main a studio backend redeploy will restore prod/healthto 200.🤖 Generated with Claude Code
https://claude.ai/code/session_013ZfTQx3v4o3aK8V8fi86ot