The module or file RescriptCore can't be found.
Report details:
The module or file RescriptCore can't be found.
- If it's a third-party dependency:
- Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in bsconfig.json?
- Did you include the file's directory to the "sources" in bsconfig.json?
- Extension version:
v1.58.0 - I created a basic project by
create-rescript-appand already installed all packages. - There isn't non-english Characters at the project path:
E:\repos\my-res
Part of Package.json:
"dependencies": {
"@rescript/core": "^1.3.0",
"rescript": "^11.1.0"
}
Visual Studio Code information:
Version: 1.85.2 (user setup)
Commit: 8b3775030ed1a69b13e4f4c628c612102e30a681
Date: 2024-01-18T06:40:10.514Z(10 mos ago)
Electron: 25.9.7
ElectronBuildld:26354273
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
Os: Windows NT x64 10.0.22621
Screenboot:
Hello, could you share your rescript.json?
Hello, could you share your
rescript.json?
Sorry, I forgot. Here:
{
"name": "rescript-project-template",
"sources": {
"dir": "src",
"subdirs": true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".res.js",
"bs-dependencies": ["@rescript/core"],
"bsc-flags": ["-open RescriptCore"]
}
Everything was generated automatically through create-rescript-app, and I didn't make any changes.
Ok, just wanted to check if you were not missing the entry in bs-dependencies.
Did npx rescript work for you? Running that again sometimes unblocks the IDE.
In your case probably pnpm exec rescript I guess. And it looks like you did not start a build or watcher yet.
In your case probably
pnpm exec rescriptI guess. And it looks like you did not start a build or watcher yet.
Ok, just wanted to check if you were not missing the entry in
bs-dependencies.Did
npx rescriptwork for you? Running that again sometimes unblocks the IDE.
I'm sure I've executed rescript and there are no errors, only the VSC extension always reports this error at the top of the file:
I just created a create-rescript-app basic project with pnpm and do not have this issue. I hope it's not windows-specific.
I guess you also tried to restart the language server from VSCode's command palette?
Other than that what does the OUTPUT tab say when you select "ReScript Language Server" from the dropdown menu?
I just created a create-rescript-app basic project with pnpm and do not have this issue. I hope it's not windows-specific.
I guess you also tried to restart the language server from VSCode's command palette?
Other than that what does the OUTPUT tab say when you select "ReScript Language Server" from the dropdown menu?
No further information beyond this:
And my system version is Windows11 22H2.
I can reproduce the error in your output if I do
pnpm run res:clean
and do not trigger a build afterwards.
But as soon as I do
pnpm run res:dev
Everything works again. And to me it really just looks like the LSP got stuck and needs a restart. Btw. when you close all rescript tabs and open one again, it also gets restarted.
I can reproduce the error in your output if I do
pnpm run res:cleanand do not trigger a build afterwards.But as soon as I do
pnpm run res:devEverything works again. And to me it really just looks like the LSP got stuck and needs a restart. Btw. when you close all rescript tabs and open one again, it also gets restarted.
I've tried to clean rescript and restart VSC, but it has no effect.
After I closed Incremental Typechecking: Enabled at settings, the problem seems to be solved:
Now I need to run res:dev all the time when developing rescript after there is type and syntax checking (LSP of the extension doesn't seem to be working), is this normal?
That's curious, maybe there is a Windows bug in path handling of incremental compilation. @zth
When incremental typechecking is off, it should still typecheck/compile after every save. Personally, I always have a watcher running in a separate terminal as this one can not get killed by the VSCode extension.
The LSP relies on a successful compile to gather type information, if you have an error in your code it might not be able to give you accurate type information.
There might very well be some issue with windows and path handling for incremental typechecking, yes.
Not so fast, GitHub.
@BIYUEHU can you try setting your extension to the pre-release version 1.59.6 and see if incremental compilation works there?
Not so fast, GitHub.
@BIYUEHU can you try setting your extension to the pre-release version 1.59.6 and see if incremental compilation works there?
I tried.Type checking is working normally:
But the first problem still exists:
Confirm to have same issue on windows. It works fine on WSL 2
this is LSP issue, on neovim the same problem :( on wsl 2 also :/
LSP Info:
[ERROR][2025-02-22 15:35:21] .../vim/lsp/rpc.lua:770 "rpc"
"C:\\Users\\user\\AppData\\Local\\nvim-data\\mason\\bin\\rescript-language-server.CMD" "stderr"
"'D:\\project\\node_modules\\.bin\\rescript' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"
I'm still having this problem on Windows with 1.62.0. It's the same problem.
Still facing this issue in Windows 11, with VSCode 1.103.2 and extension 1.65.2. The issue doesn't seem to be present in Linux.
I believe I have a fix for this, could someone try out the vsix on https://github.com/rescript-lang/rescript-vscode/actions/runs/17259865998?pr=1120
@nojaf same issue in neovim, that's not vscode ext prbolem, bug in lsp
@snatvb my fix is in LSP server, should work for neovim as well.
@nojaf Just tried the VSX, but still get the same error. (ReScript 11.1.4)
@ssmfd interesting, could you copy the contents of your lib/bs/build.ninja file.
And enable "rescript.settings.incrementalTypechecking.debugLogging": true for your workspace.
Then grab the logs from the ReScript Language Server output window:
I would like to see what you got for About to invoke bsc from ...
@nojaf Okay, so, here they are:
build.ninja contents
rescript = 1
g_finger := /mnt/C878A2AF78A29C26/prog/fandb/server-rescript/node_modules/@rescript/core/lib/ocaml/install.stamp
rule astj
command = /mnt/C878A2AF78A29C26/prog/fandb/server-rescript/node_modules/rescript/linux/bsc.exe -bs-v 11.1.4 -uncurried -open RescriptCore -absname -bs-ast -o $out $i
o src/Demo.ast : astj ../../src/Demo.res
rule deps
command = /mnt/C878A2AF78A29C26/prog/fandb/server-rescript/node_modules/rescript/linux/bsb_helper.exe -hash 13bda1cb041571eac974df229b45b3be $in
restat = 1
o src/Demo.d : deps src/Demo.ast
rule mij
command = /mnt/C878A2AF78A29C26/prog/fandb/server-rescript/node_modules/rescript/linux/bsc.exe -I src/lib/oak -I src/lib/web-api -I src/lib -I src/routers -I src/utils -I src -I /mnt/C878A2AF78A29C26/prog/fandb/server-rescript/node_modules/@rescript/core/lib/ocaml -open RescriptCore -uncurried -bs-package-name server-rescript -bs-package-output esmodule:$in_d:.res.mjs -bs-v $g_finger $i
dyndep = 1
restat = 1
o src/Demo.cmj src/Demo.cmi ../../src/Demo.res.mjs : mij src/Demo.ast
o src/Main.ast : astj ../../src/Main.res
o src/Main.d : deps src/Main.ast
o src/Main.cmj src/Main.cmi ../../src/Main.res.mjs : mij src/Main.ast
o src/Types.ast : astj ../../src/Types.res
o src/Types.d : deps src/Types.ast
o src/Types.cmj src/Types.cmi ../../src/Types.res.mjs : mij src/Types.ast
o src/AppState.ast : astj ../../src/AppState.res
o src/AppState.d : deps src/AppState.ast
o src/AppState.cmj src/AppState.cmi ../../src/AppState.res.mjs : mij src/AppState.ast
o src/utils/HttpError.ast : astj ../../src/utils/HttpError.res
o src/utils/HttpError.d : deps src/utils/HttpError.ast
o src/utils/HttpError.cmj src/utils/HttpError.cmi ../../src/utils/HttpError.res.mjs : mij src/utils/HttpError.ast
o src/utils/DataValidation.ast : astj ../../src/utils/DataValidation.res
o src/utils/DataValidation.d : deps src/utils/DataValidation.ast
o src/utils/DataValidation.cmj src/utils/DataValidation.cmi ../../src/utils/DataValidation.res.mjs : mij src/utils/DataValidation.ast
o src/routers/SessionsRouter.ast : astj ../../src/routers/SessionsRouter.res
o src/routers/SessionsRouter.d : deps src/routers/SessionsRouter.ast
o src/routers/SessionsRouter.cmj src/routers/SessionsRouter.cmi ../../src/routers/SessionsRouter.res.mjs : mij src/routers/SessionsRouter.ast
o src/lib/web-api/Headers.ast : astj ../../src/lib/web-api/Headers.res
o src/lib/web-api/Headers.d : deps src/lib/web-api/Headers.ast
o src/lib/web-api/Headers.cmj src/lib/web-api/Headers.cmi ../../src/lib/web-api/Headers.res.mjs : mij src/lib/web-api/Headers.ast
o src/lib/web-api/FormData.ast : astj ../../src/lib/web-api/FormData.res
o src/lib/web-api/FormData.d : deps src/lib/web-api/FormData.ast
o src/lib/web-api/FormData.cmj src/lib/web-api/FormData.cmi ../../src/lib/web-api/FormData.res.mjs : mij src/lib/web-api/FormData.ast
o src/lib/oak/Router.ast : astj ../../src/lib/oak/Router.res
o src/lib/oak/Router.d : deps src/lib/oak/Router.ast
o src/lib/oak/Router.cmj src/lib/oak/Router.cmi ../../src/lib/oak/Router.res.mjs : mij src/lib/oak/Router.ast
o src/lib/oak/Context.ast : astj ../../src/lib/oak/Context.res
o src/lib/oak/Context.d : deps src/lib/oak/Context.ast
o src/lib/oak/Context.cmj src/lib/oak/Context.cmi ../../src/lib/oak/Context.res.mjs : mij src/lib/oak/Context.ast
o src/lib/oak/Cookies.ast : astj ../../src/lib/oak/Cookies.res
o src/lib/oak/Cookies.d : deps src/lib/oak/Cookies.ast
o src/lib/oak/Cookies.cmj src/lib/oak/Cookies.cmi ../../src/lib/oak/Cookies.res.mjs : mij src/lib/oak/Cookies.ast
o src/lib/oak/Request.ast : astj ../../src/lib/oak/Request.res
o src/lib/oak/Request.d : deps src/lib/oak/Request.ast
o src/lib/oak/Request.cmj src/lib/oak/Request.cmi ../../src/lib/oak/Request.res.mjs : mij src/lib/oak/Request.ast
o src/lib/oak/Response.ast : astj ../../src/lib/oak/Response.res
o src/lib/oak/Response.d : deps src/lib/oak/Response.ast
o src/lib/oak/Response.cmj src/lib/oak/Response.cmi ../../src/lib/oak/Response.res.mjs : mij src/lib/oak/Response.ast
o src/lib/oak/HttpStatus.ast : astj ../../src/lib/oak/HttpStatus.res
o src/lib/oak/HttpStatus.d : deps src/lib/oak/HttpStatus.ast
o src/lib/oak/HttpStatus.cmj src/lib/oak/HttpStatus.cmi ../../src/lib/oak/HttpStatus.res.mjs : mij src/lib/oak/HttpStatus.ast
o src/lib/oak/Middleware.ast : astj ../../src/lib/oak/Middleware.res
o src/lib/oak/Middleware.d : deps src/lib/oak/Middleware.ast
o src/lib/oak/Middleware.cmj src/lib/oak/Middleware.cmi ../../src/lib/oak/Middleware.res.mjs : mij src/lib/oak/Middleware.ast
o src/lib/oak/Application.ast : astj ../../src/lib/oak/Application.res
o src/lib/oak/Application.d : deps src/lib/oak/Application.ast
o src/lib/oak/Application.cmj src/lib/oak/Application.cmi ../../src/lib/oak/Application.res.mjs : mij src/lib/oak/Application.ast
o src/lib/oak/RequestBody.ast : astj ../../src/lib/oak/RequestBody.res
o src/lib/oak/RequestBody.d : deps src/lib/oak/RequestBody.ast
o src/lib/oak/RequestBody.cmj src/lib/oak/RequestBody.cmi ../../src/lib/oak/RequestBody.res.mjs : mij src/lib/oak/RequestBody.ast
ReScript Language Server logs
About to invoke bsc from "d:\prog\fandb\server-rescript", used bsb
d:\prog\fandb\server-rescript\node_modules\rescript\win32\bsc.exe "-I" "d:\prog\fandb\server-rescript\lib\bs\src\lib\oak" "-I" "d:\prog\fandb\server-rescript\lib\bs\src\lib\web-api" "-I" "d:\prog\fandb\server-rescript\lib\bs\src\lib" "-I" "d:\prog\fandb\server-rescript\lib\bs\src\routers" "-I" "d:\prog\fandb\server-rescript\lib\bs\src\utils" "-I" "d:\prog\fandb\server-rescript\lib\bs\src" "-I" "d:\mnt\C878A2AF78A29C26\prog\fandb\server-rescript\node_modules\@rescript\core\lib\ocaml" "-open" "RescriptCore" "-uncurried" "-bs-package-name" "server-rescript" "-bs-v" "1756306508635" "-color" "never" "-ignore-parse-errors" "d:\prog\fandb\server-rescript\lib\bs\___incremental\Middleware.res"
Recompiled Middleware.res in 0.026784299999999348s
Resetting compilation status.
@ssmfd are you doing WSL things?
I see both
rule mij
command = /mnt/C878A2AF78A29C26/prog/fandb/server-rescript/node_modules/rescript/linux/bsc.exe
and
"d:\mnt\C878A2AF78A29C26\prog\fandb\server-rescript\node_modules\@rescript\core\lib\ocaml"
So, I wonder where this mix is coming from?
My fix of today, does have a "is native windows" check, so if you are not on puresang Windows, it might not be helping your situation.
@nojaf Oh, that's interesting. Sorry for that. My bad. 🤦♂️
I'm not doing WSL things, but I have that specific code project in a drive that's shared between a Windows and a Linux installation on the same computer. When the extension didn't work with Windows I tried the project from Linux and worked a bit from there. Probably that's where the "contamination" came from. I'll try it in a new project, Windows-only, and see how it goes.
Okay, I copied the same source code (and only the source code) to a newly-created Windows-only ReScript 11.1.4 project. The RescriptCore error is fixed (it seems)!
What happens now is that it can't find other modules in the same project, but I'm not sure if it's related to this fix or not. The project compiles without an issue, but VSCode shows errors like the following:
@ssmfd it is worth posting the same info I asked last time.
Also remove the lib folder and do a build before starting the IDE.
Just to confirm nothing was lingering.
@nojaf Okay, so, I:
- Closed all instances of VSCode.
- Deleted the
libfolder. - Did a rebuild.
- Opened VSCode again.
I still get errors. In case it helps, though, the errors don't appear as soon as VSCode or a .res file is opened, but after modifying one (and it only affects the modified file; if I want to trigger errors on other files, I have to modify them). This is not a post-fix behavior, though. If I restart the ReScript Language Server, all errors are gone, and appear again (on a per-file basis) as soon as I modify a file.
build.ninja contents
rescript = 1
g_finger := D:\prog\rescript-test\another-test\another-test\node_modules\@rescript\core\lib\ocaml\install.stamp
rule astj
command = "D:\prog\rescript-test\another-test\another-test\node_modules\rescript\win32\bsc.exe" -bs-v 11.1.4 -uncurried -open RescriptCore -absname -bs-ast -o $out $i
o src\Demo.ast : astj ..\..\src\Demo.res
rule deps
command = "D:\prog\rescript-test\another-test\another-test\node_modules\rescript\win32\bsb_helper.exe" -hash 4707864f2b60b42b759130196900518a $in
restat = 1
o src\Demo.d : deps src\Demo.ast
rule mij
command = "D:\prog\rescript-test\another-test\another-test\node_modules\rescript\win32\bsc.exe" -I "src\lib\oak" -I "src\lib\web-api" -I "src\lib" -I "src\routers" -I "src\utils" -I src -I "D:\prog\rescript-test\another-test\another-test\node_modules\@rescript\core\lib\ocaml" -open RescriptCore -uncurried -bs-package-name another-test -bs-package-output esmodule:$in_d:.res.mjs -bs-v $g_finger $i
dyndep = 1
restat = 1
o src\Demo.cmj src\Demo.cmi ..\..\src\Demo.res.mjs : mij src\Demo.ast
o src\Main.ast : astj ..\..\src\Main.res
o src\Main.d : deps src\Main.ast
o src\Main.cmj src\Main.cmi ..\..\src\Main.res.mjs : mij src\Main.ast
o src\Types.ast : astj ..\..\src\Types.res
o src\Types.d : deps src\Types.ast
o src\Types.cmj src\Types.cmi ..\..\src\Types.res.mjs : mij src\Types.ast
o src\AppState.ast : astj ..\..\src\AppState.res
o src\AppState.d : deps src\AppState.ast
o src\AppState.cmj src\AppState.cmi ..\..\src\AppState.res.mjs : mij src\AppState.ast
o src\utils\HttpError.ast : astj ..\..\src\utils\HttpError.res
o src\utils\HttpError.d : deps src\utils\HttpError.ast
o src\utils\HttpError.cmj src\utils\HttpError.cmi ..\..\src\utils\HttpError.res.mjs : mij src\utils\HttpError.ast
o src\utils\DataValidation.ast : astj ..\..\src\utils\DataValidation.res
o src\utils\DataValidation.d : deps src\utils\DataValidation.ast
o src\utils\DataValidation.cmj src\utils\DataValidation.cmi ..\..\src\utils\DataValidation.res.mjs : mij src\utils\DataValidation.ast
o src\routers\SessionsRouter.ast : astj ..\..\src\routers\SessionsRouter.res
o src\routers\SessionsRouter.d : deps src\routers\SessionsRouter.ast
o src\routers\SessionsRouter.cmj src\routers\SessionsRouter.cmi ..\..\src\routers\SessionsRouter.res.mjs : mij src\routers\SessionsRouter.ast
o src\lib\web-api\Headers.ast : astj ..\..\src\lib\web-api\Headers.res
o src\lib\web-api\Headers.d : deps src\lib\web-api\Headers.ast
o src\lib\web-api\Headers.cmj src\lib\web-api\Headers.cmi ..\..\src\lib\web-api\Headers.res.mjs : mij src\lib\web-api\Headers.ast
o src\lib\web-api\FormData.ast : astj ..\..\src\lib\web-api\FormData.res
o src\lib\web-api\FormData.d : deps src\lib\web-api\FormData.ast
o src\lib\web-api\FormData.cmj src\lib\web-api\FormData.cmi ..\..\src\lib\web-api\FormData.res.mjs : mij src\lib\web-api\FormData.ast
o src\lib\oak\Router.ast : astj ..\..\src\lib\oak\Router.res
o src\lib\oak\Router.d : deps src\lib\oak\Router.ast
o src\lib\oak\Router.cmj src\lib\oak\Router.cmi ..\..\src\lib\oak\Router.res.mjs : mij src\lib\oak\Router.ast
o src\lib\oak\Context.ast : astj ..\..\src\lib\oak\Context.res
o src\lib\oak\Context.d : deps src\lib\oak\Context.ast
o src\lib\oak\Context.cmj src\lib\oak\Context.cmi ..\..\src\lib\oak\Context.res.mjs : mij src\lib\oak\Context.ast
o src\lib\oak\Cookies.ast : astj ..\..\src\lib\oak\Cookies.res
o src\lib\oak\Cookies.d : deps src\lib\oak\Cookies.ast
o src\lib\oak\Cookies.cmj src\lib\oak\Cookies.cmi ..\..\src\lib\oak\Cookies.res.mjs : mij src\lib\oak\Cookies.ast
o src\lib\oak\Request.ast : astj ..\..\src\lib\oak\Request.res
o src\lib\oak\Request.d : deps src\lib\oak\Request.ast
o src\lib\oak\Request.cmj src\lib\oak\Request.cmi ..\..\src\lib\oak\Request.res.mjs : mij src\lib\oak\Request.ast
o src\lib\oak\Response.ast : astj ..\..\src\lib\oak\Response.res
o src\lib\oak\Response.d : deps src\lib\oak\Response.ast
o src\lib\oak\Response.cmj src\lib\oak\Response.cmi ..\..\src\lib\oak\Response.res.mjs : mij src\lib\oak\Response.ast
o src\lib\oak\HttpStatus.ast : astj ..\..\src\lib\oak\HttpStatus.res
o src\lib\oak\HttpStatus.d : deps src\lib\oak\HttpStatus.ast
o src\lib\oak\HttpStatus.cmj src\lib\oak\HttpStatus.cmi ..\..\src\lib\oak\HttpStatus.res.mjs : mij src\lib\oak\HttpStatus.ast
o src\lib\oak\Middleware.ast : astj ..\..\src\lib\oak\Middleware.res
o src\lib\oak\Middleware.d : deps src\lib\oak\Middleware.ast
o src\lib\oak\Middleware.cmj src\lib\oak\Middleware.cmi ..\..\src\lib\oak\Middleware.res.mjs : mij src\lib\oak\Middleware.ast
o src\lib\oak\Application.ast : astj ..\..\src\lib\oak\Application.res
o src\lib\oak\Application.d : deps src\lib\oak\Application.ast
o src\lib\oak\Application.cmj src\lib\oak\Application.cmi ..\..\src\lib\oak\Application.res.mjs : mij src\lib\oak\Application.ast
o src\lib\oak\RequestBody.ast : astj ..\..\src\lib\oak\RequestBody.res
o src\lib\oak\RequestBody.d : deps src\lib\oak\RequestBody.ast
o src\lib\oak\RequestBody.cmj src\lib\oak\RequestBody.cmi ..\..\src\lib\oak\RequestBody.res.mjs : mij src\lib\oak\RequestBody.ast
ReScript Language Server logs
About to invoke bsc from "d:\prog\rescript-test\another-test\another-test", used bsb
d:\prog\rescript-test\another-test\another-test\node_modules\rescript\win32\bsc.exe "-I" "src\lib\oak" "-I" "src\lib\web-api" "-I" "src\lib" "-I" "src\routers" "-I" "src\utils" "-I" "d:\prog\rescript-test\another-test\another-test\lib\bs\src" "-I" "D:\prog\rescript-test\another-test\another-test\node_modules\@rescript\core\lib\ocaml" "-open" "RescriptCore" "-uncurried" "-bs-package-name" "another-test" "-bs-v" "1756309358405" "-color" "never" "-ignore-parse-errors" "d:\prog\rescript-test\another-test\another-test\lib\bs\___incremental\Middleware.res"
Recompiled Middleware.res in 0.025085699999999635s
Resetting compilation status.
I still get errors.
Could you be more specific, what exactly do you get?
Can you provide a sample repo, I did some more testing on Windows and all did seem to work.
One thing I noticed is that, certain things are not picked up like installing a new package without a rescript build will not work. But that is not Windows specific I believe.
I merged my PR as I do believe it is a step in the right direction. Other people can try out the prerelease version.
Allow me to try a few things and I'll come back with a sample repo, at least (if not more useful info on why the problem is happening in my specific case). Thanks a lot for your time. 🙏
As for the "I still get errors", I meant the same errors I was getting in my previous comment: