Closed aukeroorda closed 1 year ago
Have you tried updating to the lastest rascal-lsp? v0.9.0 was released in companion to the newest rascal release, and rascal-vscode extension.
This looks rather iffy. Let's try and have a call on Monday?
Is there a module called Node
in your project, without any folder around it? I think this may break the loading of util::LanguageServer because it imports Node
from the standard library. Somehow the latest release changed the order in the search path and that leads to this problem.
Other library modules that import Node
run into similar issues as you can see.
Hi - Thanks for looking into this so quick!
Have you tried updating to the lastest rascal-lsp? v0.9.0 was released in companion to the newest rascal release, and rascal-vscode extension.
This solves the issue of solely importing `util::LanguageServer`
INFO: detected |lib://rascal-lsp| at |jar+file:///Users/auke/.vscode/extensions/usethesource.rascalmpl-0.9.0/assets/jars/rascal-lsp.jar!/|
INFO: detected |lib://rascal| at |jar+file:///Users/auke/.vscode/extensions/usethesource.rascalmpl-0.9.0/assets/jars/rascal.jar!/|
INFO: resolved |lib://rascal-lsp| at |jar+file:///Users/auke/.vscode/extensions/usethesource.rascalmpl-0.9.0/assets/jars/rascal-lsp.jar!/|
Rascal Version: 0.33.7
Rascal-lsp Version: 2.18.0
pathConfig(
ignores=[],
javaCompilerPath=[
|file:///Users/auke/.vscode/extensions/usethesource.rascalmpl-0.9.0/assets/jars/rascal-lsp.jar|,
|file:///Users/auke/.vscode/extensions/usethesource.rascalmpl-0.9.0/assets/jars/rascal.jar|
],
bin=|target://salix-corel|,
classloaders=[
|target://salix-corel|,
|system:///|,
|lib://rascal-lsp|
],
libs=[|lib://rascal|],
srcs=[
|lib://rascal-lsp|,
|file:///Users/auke/salix-corel/src/main/rascal|
])INFO: resolved |lib://rascal| at |jar+file:///Users/auke/.vscode/extensions/usethesource.rascalmpl-0.9.0/assets/jars/rascal.jar!/|
rascal>import util::LanguageServer;
ok
rascal>
However,
Is there a module called Node in your project, without any folder around it? I think this may break the loading of util::LanguageServer because it imports Node from the standard library. Somehow the latest release changed the order in the search path and that leads to this problem.
This is almost the case, as there is a module module salix::Node
in my project, but inside the salix
directory.
For this comment I was trying to construct a minimal reproducible example, as the error still occurred when trying to import a module that used util::LanguageServer
, or so I thought. In the process of constructing a minimal reproducible example, I cleared and restarted my terminal a couple of times, so I cannot provide the exact steps I did :(.
I started by importing my main module, that imports a bunch of other modules. The error stated that an import could not be loaded, so I went on and tried manually importing that module directly in the REPL. This then gave me a next module that could not be imported, until I eventually reached a single 'leaf' module that did not import any other modules, my corel::Syntax
module. After finally importing this in the REPL, the error went away.
The error was in the form of:
|prompt:///|(0,28,<1,0>,<1,28>):Could not load util::LanguageServer due to: Undeclared variable: unsetRec
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/UndeclaredVariable| at |std:///lang/rascal/grammar/ParserGenerator.rsc|(13469,8,<291,32>,<291,40>)
|std:///lang/rascal/grammar/ParserGenerator.rsc|(13469,8,<291,32>,<291,40>): Undeclared variable: unsetRec
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/UndeclaredVariable|
Mysterious! If we ever end up in this corner again, let's reopen the issue. Thanks for the info @aukeroorda
When working on the project today, the issue has reappeared, as in, it is the same set of errors, but for a different module. There is a very strange inconsistency, as there is a simple module that can be imported in a fresh REPL, but not in one where the issue with the node
module name mismatch has occurred. This is what I have done:
If you'd like, and have the time, you could join the meeting I have with @tvdstorm today, at 1pm.
I'll see what renaming the salix::Node
module achieves, and whether adding a pom file solves this issue. I've added you as collaborator to the project in which I'm working @jurgenvinju.
Bug reproduced here.
having or not-having a pom.xml in the project makes no difference
Renaming the salix::Node
module to salix::NamechangedNode
works. Use the shell script namechangecommand.sh
on the rename-salix-node
branch if you want to reproduce: https://github.com/aukeroorda/salix-corel/tree/rename-salix-node
Note that this changed module name still ends in Node
, but the name itself is prefixed.
Ok.
found : |std:///ListRelation.rsc|
found : |cwd:///Node.rsc|
|std:///vis/Text.rsc|(948,12,<27,0>,<27,12>):Could not load Node due to: Module name salix::Node does not match Node
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/ModuleNameMismatch| at |std:///vis/Text.rsc|(948,12,<27,0>,<27,12>)
|std:///vis/Text.rsc|(948,12,<27,0>,<27,12>):Module name salix::Node does not match Node
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/ModuleNameMismatch|
ok
rascal>|cwd:///|.ls
list[loc]: [
|cwd:///demo|,
|cwd:///HTML.rsc|,
|cwd:///LspData.rsc|,
|cwd:///util|,
|cwd:///Node.rsc|,
|cwd:///cytoscape|,
|cwd:///SVG.rsc|,
|cwd:///Core.rsc|,
|cwd:///charts|,
|cwd:///App.rsc|,
|cwd:///Diff.rsc|,
|cwd:///salix.js|,
|cwd:///Index.rsc|,
|cwd:///mermaid|,
|cwd:///ace|
]
rascal>import Location;
found : |std:///Location.rsc|
found : |std:///Set.rsc|
found : |std:///String.rsc|
ok
rascal>import IO;
found : |std:///IO.rsc|
ok
rascal>resolveLocation(|cwd:///|)
loc: |file:///Users/jurgenv/git/salix-corel/src/main/rascal/salix/|
So the CWD is also on the path, and this breaks the module resolution code.
private registerMainRun() {
this.context.subscriptions.push(
vscode.commands.registerTextEditorCommand("rascalmpl.runMain", (text, _edit, moduleName) => {
if (!text.document.uri || !moduleName) {
return;
}
this.startTerminal(text.document.uri, "--loadModule", moduleName, "--runModule"); // here we pass the URI that becomes the CWD
})
);
}
private registerImportModule() {
this.context.subscriptions.push(
vscode.commands.registerTextEditorCommand("rascalmpl.importModule", (text, _edit, moduleName) => {
if (!text.document.uri || !moduleName) {
return;
}
this.startTerminal(text.document.uri, "--loadModule", moduleName); // here we pass the URI that becomes the CWD
})
);
}
This is the cause in RascalExtension.ts
the parent of text.document.uri
is used as the cwd
private startTerminal(uri: vscode.Uri | undefined, ...extraArgs: string[]) {
return vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
cancellable: false,
title: "Rascal terminal"
}, async (progress) => {
progress.report({message: "Starting rascal-lsp"});
const rascal = await this.rascal.rascalClient;
console.log(`Starting Rascal REPL: on ${uri} and with args: ${extraArgs}`);
if (uri && !uri.path.endsWith(".rsc")) {
// do not try to figure out a rascal project path when the focus is not a rascal file
uri = undefined;
}
progress.report({increment: 25, message: "Requesting IDE configuration"});
const serverConfig = await rascal.sendRequest<IDEServicesConfiguration>("rascal/supplyIDEServicesConfiguration");
progress.report({increment: 25, message: "Calculating project class path"});
const compilationPath = await rascal.sendRequest<string[]>("rascal/supplyProjectCompilationClasspath", { uri: uri?.toString() });
progress.report({increment: 25, message: "Creating terminal"});
const terminal = vscode.window.createTerminal({
iconPath: this.icon,
cwd: path.dirname(uri?.fsPath || ""), // this is where we use the given uri for the CWD
shellPath: await getJavaExecutable(),
shellArgs: this.buildShellArgs(compilationPath, serverConfig, ...extraArgs),
name: 'Rascal Terminal',
});
terminal.show(false);
progress.report({increment: 25, message: "Finished creating terminal"});
});
}
So know we know everything. All we need is a fix.
In reality the CWD here should not be anything related to the project or another library. The user's home directory would be fine.
@tvdstorm @aukeroorda the problem is now diagnosed; thinking about the solution.
@aukeroorda workaround: if you start a terminal from a module (parent folder) that does not contain a Node
module, there is no such effect.
The fix fixes the problem; tested this here.
v0.9.1 is released to include this bugfix. Thanks @aukeroorda for the clear bug reports and patience in testing.
Describe the bug
My project stopped working, as the import of the module
util::LanguageServer
inside my code fails. Opening a fresh rascal terminal and importing the module results in the same errors. This started 15 minutes ago, after daily and continued use of this library for the past week.To Reproduce
Steps to reproduce the behavior:
import util::LanguageServer;
Expected behavior I expect the
util::LanguageServer
import to work.Stack traces
Desktop (please complete the following information):