1

I am trying to start rascal with clair from the command line, however I do not understand why this happens:

java -cp "rascal-0.18.0.jar;clair_0.1.0.202005281059.jar;org.eclipse.cdt.core_6.11.0.202003081657.jar" org.rascalmpl.shell.RascalShell
Version: 0.18.0
INFO: detected |lib://rascal| at |jar+file:///C:/ws/rascal-0.18.0.jar!/|
INFO: detected |lib://clair| at |jar+file:///C:/ws/clair_0.1.0.202005281059.jar!/|
rascal>

But when the order of the jars changes, it fails:

java -cp "clair_0.1.0.202005281059.jar;rascal-0.18.0.jar;org.eclipse.cdt.core_6.11.0.202003081657.jar" org.rascalmpl.shell.RascalShell
Version: 0.18.0
INFO: detected |lib://clair| at |jar+file:///C:/ws/clair_0.1.0.202005281059.jar!/|
INFO: detected |lib://rascal| at |jar+file:///C:/ws/rascal-0.18.0.jar!/|
main function should either have one argument of type list[str], or keyword parameters
Usage: java -jar ...

Is this normal behavior with classpaths?

Note: The clair jar does not contain a org.rascalmpl.shell.RascalShell class.

Update: Removing from META-INF/RASCAL.MF the line:

Main-Function: main
Main-Module: lang::cpp::IDE

resolves the problem, so it seems to be an issue with Rascal (and a rascal function) and not with Java (and a Java function).

tillaert
  • 1,797
  • 12
  • 20
  • Potential duplicate: https://stackoverflow.com/questions/3796211/is-the-order-of-the-value-inside-the-classpath-matter – Lino Jun 10 '20 at 08:13
  • I've added a note. There does not seem to be any duplicate classes. – tillaert Jun 10 '20 at 08:42
  • also, I cannot imagine clair working on command line, it needs a version of CDT and the connected eclipse setup. We currently do not repackage this in a jar as we do for the jdt. – Davy Landman Jun 10 '20 at 09:57
  • Sometimes I have the problem that in Eclipse Rascal find Clair raised exceptions. I had to reinstall Rascal and Clair. Could it have something to do with their order in the classpath? – tillaert Jun 10 '20 at 10:52
  • 1
    Do not think so, but if you can reproduce it, we would really appreciate a bug report on the github repo :) – Davy Landman Jun 11 '20 at 20:19

2 Answers2

1

I think you have found two bugs in the REPL:

  1. The second behavior is the bug that we try to run the Main-Function definition which is intended for the IDE plugin, also in the terminal. I think the issue/bug is that we use the same configuration for command line as ide integration point, we might need to add a seperate tag for this.
  2. We should provide a way to say which RASCAL.MF we want to run, since now it just picks the first one it sees (rascal also has a RASCAL.MF file).
Davy Landman
  • 15,109
  • 6
  • 49
  • 73
  • that Main-Function thing is not per se intended for the IDE plugin. It is meant to facilitate Rascal applications that start somehow, let's say from `java -jar myRascalApp.jar`. In particular that was designed for the situation where we did not have any library support so there would be 1 jar with one RASCAL.MF. – Jurgen Vinju Jun 10 '20 at 09:29
  • at 2: RASCAL.MF:Main-Module is parallel to MANIFEST.MF:Main-Class which also depends on classpath order. – Jurgen Vinju Jun 10 '20 at 09:31
  • I mean that it's used both bye the IDE and the REPL and that there is no way to currently support both *in parallel* from the same RASCAL.MF file. – Davy Landman Jun 10 '20 at 09:54
  • Right; but that's not a bug since it wasn't a feature ever either. There is no way to support two different java MaiN-Class attributes either for the same jar file. – Jurgen Vinju Jun 10 '20 at 12:17
1

RascalShell's main function behaves differently if there are commandline parameters and differently depending on the first RASCAL.MF file it finds in the classpath.

  • If there is a parameter, then it loads that parameter as a module name and invokes the main function in that module, passing it the other commandline parameters
  • Otherwise it starts the REPL
  • But: if the first RASCAL.MF file it finds in the classpath has a Main-Module and a Main-Function, then it loads this module always and starts its main function.

I suspect the latter is at work: the order of the classpath changes which RASCAL.MF file is found and therefore the REPL does not start but some module is being loaded and not found. I'm not sure though, since I can't set a breakpoint from here ;-)

Jurgen Vinju
  • 6,393
  • 1
  • 15
  • 26
  • So if you want the repl always put the Rascal jar first, if you want to run an app written in Rascal but the Rascal jar last. – Jurgen Vinju Jun 10 '20 at 09:45