Skip to content

fix(lsp): resolve highlights.scm via tree-sitter-rsm package root - #84

Merged
leotrs merged 1 commit into
mainfrom
fix/rsm-lsp-highlights-scm-resolution
Jul 2, 2026
Merged

fix(lsp): resolve highlights.scm via tree-sitter-rsm package root#84
leotrs merged 1 commit into
mainfrom
fix/rsm-lsp-highlights-scm-resolution

Conversation

@leotrs

@leotrs leotrs commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Problem

rsm-lsp crashes at startup in the prod/Docker layout:

Error: Could not find highlights.scm in any expected location
    at SemanticTokensProvider.loadHighlightQuery (dist/layer1/semanticTokens.js:140)

This takes the LSP process down under supervisord and makes the Studio backend /health return 503 (the services check reports lsp 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 containerized node_modules layout:

  • The two __dirname-relative paths assume a tree-sitter-rsm checkout adjacent to the repo root (dev/monorepo layout). In the Docker image tree-sitter-rsm lives 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/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, not ../queries.

This has been broken in the prod layout since semantic tokens were added; the dev path (../../../../tree-sitter-rsm/... from src/) 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_modules in prod). The __dirname-relative paths remain as fallbacks.

Verification

  • tsc builds clean.
  • Running the resolution from the compiled dist/layer1 context finds tree-sitter-rsm/queries/highlights.scm (EXISTS = true).
  • 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.

Rollout

Studio's deploy clones aris-pub/rsm main and rebuilds rsm-lsp, so once this merges to rsm main a studio backend redeploy will restore prod /health to 200.

🤖 Generated with Claude Code

https://claude.ai/code/session_013ZfTQx3v4o3aK8V8fi86ot

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
@leotrs
leotrs merged commit 3363294 into main Jul 2, 2026
15 checks passed
@leotrs
leotrs deleted the fix/rsm-lsp-highlights-scm-resolution branch July 2, 2026 12:22
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.

1 participant