rescript-vscode icon indicating copy to clipboard operation
rescript-vscode copied to clipboard

v12.beta1 - LSP is not working. Maybe related to pnpm but I'm not sure

Open DZakh opened this issue 5 months ago • 19 comments

  1. Go to the branch https://github.com/DZakh/sury/tree/rescript-v12.beta
  2. Run pnpm i && pnpm res from the root
  3. See how in packages/sury/src/Sury.res LSP is not working

I also tried with a legacy compiler. And opening the packages/sury folder separately.

I assume might be caused by using pnpm.

DZakh avatar Jul 12 '25 10:07 DZakh

ReScript tooling: Internal error. Something broke. Here's the error message that you can report if you want: Error: Command failed: /Users/dzakh/.cursor/extensions/chenglou92.rescript-vscode-1.62.0-universal/server/analysis_binaries/darwinarm64/rescript-editor-analysis.exe hover /Users/dzakh/code/DZakh/rescript-schema/packages/sury/src/Sury.res 3456 9 /var/folders/pv/vz3qt1p52g72mw05tb7gzgy00000gn/T/rescript_format_file_44871_21 true (this message will only be reported once every 15 minutes)

DZakh avatar Jul 12 '25 10:07 DZakh

Well, I'm actually not sure of pnpm, since it worked with v11.

DZakh avatar Jul 12 '25 10:07 DZakh

The lockfile got renamed, we didn't take this into account yet. It hasn't been 24 hours since the beta came out...

nojaf avatar Jul 12 '25 11:07 nojaf

Still have the problem with beta.5, now with the binary file not being found.

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/dzakh/code/DZakh/rescript-schema/packages/sury/node_modules/@rescript/darwin-arm64/bin.js' imported from /Users/dzakh/.cursor/extensions/chenglou92.rescript-vscode-1.64.0-universal/server/out/cli.js
    at finalizeResolution (node:internal/modules/esm/resolve:283:11)
    at moduleResolve (node:internal/modules/esm/resolve:959:10)
    at defaultResolve (node:internal/modules/esm/resolve:1195:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:642:12)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:591:25)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:574:38)
    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:236:38)
    at ModuleLoader.import (node:internal/modules/esm/loader:539:34)
    at defaultImportModuleDynamicallyForScript (node:internal/modules/esm/utils:228:31)
    at importModuleDynamicallyCallback (node:internal/modules/esm/utils:250:12) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///Users/dzakh/code/DZakh/rescript-schema/packages/sury/node_modules/@rescript/darwin-arm64/bin.js'
}

Solved it by manually installing "@rescript/darwin-arm64": "12.0.0-beta.5", as a dev dependency, but I assume it should be working automatically.

DZakh avatar Aug 12 '25 06:08 DZakh

Probably this is a ReScript repo issue 🤔

DZakh avatar Aug 12 '25 06:08 DZakh

any ideas on how to fix this?

tx46 avatar Sep 17 '25 08:09 tx46

This might the same problem as in https://github.com/rescript-lang/rescript-vscode/issues/1127. I think the solution is https://github.com/rescript-lang/rescript-vscode/issues/1127#issuecomment-3291275266

In https://github.com/rescript-lang/rescript/pull/7889, I'm storing the bsc path used in compilation in a JSON file. Tooling should be able to pick this up once available.

nojaf avatar Sep 17 '25 09:09 nojaf

Could you both try out latest beta (12) and latest vsix (1.65.7).

If it doesn't work, try post the result of the Dump LSP Server State command.

nojaf avatar Sep 25 '25 11:09 nojaf

i'm not sure what you mean by 1.65.7. i had 1.64.0 and then did a switch to @next, which gave me 1.65.0-next-c1b3031.0.

i'm on emacs btw, not vscode. this still does not work with pnpm (but works fine with npm and also bun):

node:internal/modules/esm/resolve:275
    throw new ERR_MODULE_NOT_FOUND(
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '<project path>/node_modules/@rescript/linux-x64/bin.js' imported from ~/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@rescript/language-server/out/cli.js
    at finalizeResolution (node:internal/modules/esm/resolve:275:11)
    at moduleResolve (node:internal/modules/esm/resolve:860:10)
    at defaultResolve (node:internal/modules/esm/resolve:984:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:685:12)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:634:25)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:617:38)
    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:273:38)
    at onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:577:36)
    at TracingChannel.tracePromise (node:diagnostics_channel:344:14)
    at ModuleLoader.import (node:internal/modules/esm/loader:576:21) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///<project path>/node_modules/@rescript/linux-x64/bin.js'
}

Node.js v22.14.0

tx46 avatar Sep 26 '25 23:09 tx46

language-server@next is entirely unusable for me in emacs and just crashes constantly with stuff like:

Error: Command failed: <project path>/node_modules/.pnpm/@[email protected]/node_modules/@rescript/linux-x64/bin/rescript-editor-analysis.exe hover SomeFileInTheProject.res 22 16 /tmp/rescript_format_file_11770_2 false
    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at checkExecSyncError (node:child_process:882:11)
    at Object.execFileSync (node:child_process:918:15)
    at Rt (~/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@rescript/language-server/out/cli.js:40:6642)
    at lt (~/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@rescript/language-server/out/cli.js:40:6854)
    at jw (~/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@rescript/language-server/out/cli.js:46:6748)
    at wi.Ry [as callback] (~/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@rescript/language-server/out/cli.js:46:16936)
    at Object.thunk (~/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@rescript/language-server/out/cli.js:3:547) {
  status: null,
  signal: 'SIGSEGV',
  output: [ null, <Buffer >, <Buffer > ],
  pid: 12135,
  stdout: <Buffer >,
  stderr: <Buffer >

1.64 works fine (with npm and bun, but not pnpm)

tx46 avatar Sep 26 '25 23:09 tx46

ok, i got something working:

  1. i need beta 13 (12 not working, might be https://github.com/rescript-lang/rescript/pull/7889 that fixes it?)
  2. i need to install @rescript/linux-x64@ci in the project
  3. i use @rescript/language-server@next (1.65.0-next-c1b3031.0)

this seems to work with only intermittent crashes, and also i get a warning during startup:

⛔ Warning (lsp-mode): Unknown notification: rescript/compilationStatus

other than that, it's actually functional

tx46 avatar Sep 27 '25 00:09 tx46

i need to install @rescript/linux-x64@ci in the project

I would expect that is no longer a requirement. Does your compiler-info.json look fine? Can you post that?

nojaf avatar Sep 29 '25 07:09 nojaf

i need to install @rescript/linux-x64@ci in the project

I would expect that is no longer a requirement. Does your compiler-info.json look fine? Can you post that?

i think it's needed, or at least it wouldn't work until i installed it..

{
  "version": "12.0.0-beta.13",
  "bsc_path": "<project path>/node_modules/.pnpm/@[email protected]/node_modules/@rescript/linux-x64/bin/bsc.exe",
  "bsc_hash": "1841d2f845430dd2e3448056c0dfb2c6710a9d9a447b11af781ed06c52c276c6",
  "rescript_config_hash": "90bb8e2f7c795b12902b9b0cc0a7a76076cf19149bcc7f061334a63f55ff7d09",
  "runtime_path": "<project path>/node_modules/.pnpm/@[email protected]/node_modules/@rescript/runtime",
  "generated_at": "1759196003428"
}

does this look as it should?

tx46 avatar Sep 30 '25 01:09 tx46

does this look as it should?

It does, but that looks to me like you are using the @rescript+linux-x64 dependency from ReScript and not the explicit install.

@DZakh does it work for you now? Can we close this?

nojaf avatar Sep 30 '25 07:09 nojaf

does this look as it should?

It does, but that looks to me like you are using the @rescript+linux-x64 dependency from ReScript and not the explicit install.

@DZakh does it work for you now? Can we close this?

i just tried pnpm removing the @rescript/linux-x64@ci package and the lsp immediately stops working with this again:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '<project path>/node_modules/@rescript/linux-x64/bin.js' imported from ~/.local/share/pnpm/global/5/.pnpm/@[email protected]/node_modules/@rescript/language-server/out/cli.js
    at finalizeResolution (node:internal/modules/esm/resolve:275:11)
    at moduleResolve (node:internal/modules/esm/resolve:860:10)
    at defaultResolve (node:internal/modules/esm/resolve:984:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:685:12)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:634:25)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:617:38)
    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:273:38)
    at onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:577:36)
    at TracingChannel.tracePromise (node:diagnostics_channel:344:14)
    at ModuleLoader.import (node:internal/modules/esm/loader:576:21) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file://<project path>/node_modules/@rescript/linux-x64/bin.js'
}

compiler-info.json:

{
  "version": "12.0.0-beta.13",
  "bsc_path": "<repo root>/node_modules/.pnpm/@[email protected]/node_modules/@rescript/linux-x64/bin/bsc.exe",
  "bsc_hash": "1841d2f845430dd2e3448056c0dfb2c6710a9d9a447b11af781ed06c52c276c6",
  "rescript_config_hash": "29abb8a0969242d5b126e9717c2ef29c52287a236b4aaf3258d1be9b212c0a13",
  "runtime_path": "<repo root>/node_modules/.pnpm/@[email protected]/node_modules/@rescript/runtime",
  "generated_at": "1759373668071"
}

is this because its a monorepo? project path != repo root

tx46 avatar Oct 02 '25 02:10 tx46

Thanks, for this report, I can see where things can still go wrong with pnpm.

nojaf avatar Oct 02 '25 06:10 nojaf

@tx46 can you give 1.65.9 a spin?

nojaf avatar Oct 02 '25 08:10 nojaf

@tx46 can you give 1.65.9 a spin?

works now!

tx46 avatar Oct 02 '25 08:10 tx46

@DZakh can we close this?

nojaf avatar Dec 14 '25 10:12 nojaf

Going to close this, please open a new issue if related problems pop up.

nojaf avatar Dec 23 '25 11:12 nojaf