-
Notifications
You must be signed in to change notification settings - Fork 62
fix: resolve symlinks when finding platform binaries #1154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: resolve symlinks when finding platform binaries #1154
Conversation
This fixes an issue where the extension fails to find ReScript platform binaries (like bsc.exe) when using package managers that use symlinked node_modules structures, such as Deno and pnpm. The issue occurs because `path.join(rescriptDir, "..")` performs string manipulation rather than following the symlink. When `node_modules/rescript` is a symlink (e.g., to `.deno/rescript@12.0.0/node_modules/rescript`), the parent directory resolves to `node_modules/` instead of the actual parent where `@rescript/darwin-arm64` etc. are located. Using `fs.realpathSync()` to resolve the symlink first ensures the correct parent directory is found.
|
Hello, I'm curious about this change. What does your Can you do a dump of the lsp server state? What do you see there? |
Yes, I patched the extension locally and have been developing with it without issues. Here's my {
"version": "12.0.0",
"bsc_path": "/Users/han-tyumi/Code/javascript/rescript/gracefully-hooked/node_modules/.deno/@rescript+darwin-arm64@12.0.0/node_modules/@rescript/darwin-arm64/bin/bsc.exe",
"bsc_hash": "b9ee425ca842260e47bee75b5d05fce7c14e3fa37f1206b07efd3c889bad3b33",
"rescript_config_hash": "a1cbd8ce74ea4ffa41e8e58825182151180230d5c658f58180ac101390dde946",
"runtime_path": "/Users/han-tyumi/Code/javascript/rescript/gracefully-hooked/node_modules/.deno/@rescript+runtime@12.0.0/node_modules/@rescript/runtime",
"generated_at": "1764397204220"
}And the LSP Server State: {
"config": {
"askToStartBuild": true,
"inlayHints": {
"enable": false,
"maxLength": 25
},
"codeLens": false,
"signatureHelp": {
"enabled": true,
"forConstructorPayloads": true
},
"incrementalTypechecking": {
"enable": true,
"acrossFiles": false,
"debugLogging": false
},
"cache": {
"projectConfig": {
"enable": true
}
},
"binaryPath": null,
"platformPath": null,
"runtimePath": null,
"compileStatus": {
"enable": true
}
},
"projects": [],
"workspaceFolders": [
"/Users/han-tyumi/Code/javascript/rescript/gracefully-hooked"
]
} |
|
The fact that Are you on the latest version of the extension? If you are, I would try and troubleshoot why rescript-vscode/server/src/utils.ts Lines 98 to 116 in ae73a0a
|
|
Yes, I'm on version 1.70.0 of the extension. You're right that when To reproduce, I reverted my fix locally, deleted The extension tries to import from Since Using |
|
Hmm, I see. I'm in a bun project and using isolated linking and this indeed is a problem if I do not have a Using I think the more proper fix here would be to have invoke the rescript binary and return the compiler-info.json if it does not exist. We can use the symlink for the time being. Thanks |
This fixes an issue where the extension fails to find ReScript platform binaries (like bsc.exe) when using package managers that use symlinked node_modules structures, such as Deno and pnpm.
The issue occurs because
path.join(rescriptDir, "..")performs string manipulation rather than following the symlink. Whennode_modules/rescriptis a symlink (e.g., to.deno/rescript@12.0.0/node_modules/rescript), the parent directory resolves tonode_modules/instead of the actual parent where@rescript/darwin-arm64etc. are located.Using
fs.realpathSync()to resolve the symlink first ensures the correct parent directory is found.