gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
304 stars 99 forks source link

Headless do not handle whitespace in path #2963

Closed RoiArthurB closed 4 years ago

RoiArthurB commented 4 years ago

Describe the bug When launching the GAMA Headless, if there's any whitespace in a path to a model/anything the script won't consider it and return an error

To Reproduce Steps to reproduce the behavior:

  1. Go to ./GAMA/headless
  2. Try to launch the headless with relative/absolute path. eg
    $ ./gama-headless.sh -xml Comparison "/home/roiarthurb/Documents/WORK/CoVid19/Containment Policies/models/experiment/Comparison Of 3 Measures.gaml" /tmp/out.xml
  3. See error

Expected behavior Catch whitespaces

Logs

!SESSION 2020-03-31 13:13:13.547 -----------------------------------------------
eclipse.buildId=${build.id}
java.version=1.8.0_242
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  -application msi.gama.headless.id4 -xml Comparison /home/roiarthurb/Documents/WORK/CoVid19/Containment Policies/models/experiment/Comparison Of 3 Measures.gaml /tmp/out.xml
Command-line arguments:  -application msi.gama.headless.id4 -data .work5628 -xml Comparison /home/roiarthurb/Documents/WORK/CoVid19/Containment Policies/models/experiment/Comparison Of 3 Measures.gaml /tmp/out.xml

!ENTRY org.eclipse.osgi 4 0 2020-03-31 13:13:17.353
!MESSAGE Application error
!STACK 1
java.io.IOException: Model file does not exist: /home/roiarthurb/.local/share/GAMA_Continuous_Linux/headless/Measures.gaml
        at msi.gama.headless.core.HeadlessSimulationLoader.loadModel(HeadlessSimulationLoader.java:107)
        at msi.gama.headless.core.HeadlessSimulationLoader.loadModel(HeadlessSimulationLoader.java:84)
        at msi.gama.headless.core.HeadlessSimulationLoader.loadModel(HeadlessSimulationLoader.java:66)
        at msi.gama.headless.job.JobPlan.loadModelAndCompileJob(JobPlan.java:77)
        at msi.gama.headless.script.ExperimentationPlanFactory.buildExperiment(ExperimentationPlanFactory.java:121)
        at msi.gama.headless.runtime.Application.buildXML(Application.java:243)
        at msi.gama.headless.runtime.Application.start(Application.java:209)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:661)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:597)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1476)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1449)
        at org.eclipse.core.launcher.Main.main(Main.java:44)

Desktop (please complete the following information):

Additional information The script remove escaped whitespace (\) and quoted string.

Workaround It's possible to fix it by launching the headless by hand (without the provided script)

AlexisDrogoul commented 4 years ago

Unbelievable that we still have these kinds of issues ... !

RoiArthurB commented 4 years ago

I'll push an update for the script to escape whitespaces for all parameters, but it doesn't solve the bug. It means that that bug comes from the headless itself (not the script to launch it).

hqnghi88 commented 4 years ago

I tested on win (may be not the case) , space work (with double quotes of course) image image What i wonder is how your path can convert from /home/roiarthurb/Documents/WORK/CoVid19/Containment Policies/models/experiment/Comparison Of 3 Measures.gaml to java.io.IOException: Model file does not exist: /home/roiarthurb/.local/share/GAMA_Continuous_Linux/headless/Measures.gaml Any special mechanism that can return .local/share??

RoiArthurB commented 4 years ago

I did tweak the default gama-headless.sh to escape the whitespaces (with a back slash) which should work the same as adding quotes...

Otherwise you're true, double quotes did the trick (I don't know what I previously did wrong). This command worked :

$ java -cp ../plugins/org.eclipse.equinox.launcher_1.5.300.v20190213-1655.jar -Xms512m -Xmx4096m -Djava.awt.headless=true org.eclipse.core.launcher.Main -application msi.gama.headless.id4 -data .work5749 -xml Comparison "/home/roiarthurb/Documents/WORK/CoVid19/Containment Policies/models/experiment/Comparison Of 3 Measures.gaml" /tmp/out.xml
> JAI/ImageIO subsystem activated
Parameter file saved at: /tmp/out.xml

So I'll update again the script to properly put both last parameters between quotes :)

I'll also dig a bit in the headless to see if we can't have it both working (which would be the best solution)

RoiArthurB commented 4 years ago

Ok guys, so I dug the problem very deeply and, long story short, it was a POSIX problem in the launching script. So the headless seems to be working fine (without trouble with witespaces in path), I re-fixed the launching script, just have to check if the script works as well on Mac than on Linux and I commit it !