khiops icon indicating copy to clipboard operation
khiops copied to clipboard

Khiops Desktop doesn't print log in stderr in case of Java error

Open bruno-at-orange opened this issue 1 year ago • 3 comments

Description

When java is misconfigured, the java GUI is not launched and nothing is print in the console. The only way to get a log is by using the -e flag :

$ khiops -e error.log
$ cat error.log
error : Java : Unable to load libjvm.so (libjvm.so: cannot open shared object file: No such file or directory)lor check the LD_LIBRARY_PATH variable
error : Unable to load GUI, use -b and -i flags to launch khiops in batch mode (khiops -h for help)

It would be better to have this log directly in the stderr, the users would see the problem immediately.

Questions/Ideas

  • It will be fixed by switching the AddError to AddFatalError in the method UIObject::GetJNIEnv().

Context

  • Khiops version 10.2.0
  • Linux

bruno-at-orange avatar Feb 20 '24 08:02 bruno-at-orange

I faced this issue too. IMHO it would be better to catch the error case in the khiops-env shell script to give a feedback to the end-user

if [[ -n $JAVA_HOME ]]; then
   KHIOPS_CLASSPATH=/usr/share/khiops/norm.jar:/usr/share/khiops/khiops.jar
   KHIOPS_JAVA_PATH=$(find -L "$JAVA_HOME" -name libjvm.so | xargs dirname)
else
   echo "We couldn't find your JVM installation. Please set the JAVA_HOME environment variable"
fi

tramora avatar Feb 22 '24 15:02 tramora

My bad. As @popescu-v reminds me the postinst script of the khiops package updates now well the khiops-env script file : it sets automatically the JAVA_HOME or shows a warning to the end user.

May be one error case left then (that can lead to the error @bruno-at-orange refers to) : the path set in JAVA_HOME is no longer valid for whatever reason (desinstallation of the JVM or upgrade to a newer version).

tramora avatar Feb 22 '24 23:02 tramora

if JAVA_HOME is no longer valid, khiops prints an error. No need to catch it in the khiops-env script, but of course the user have to see it.

bruno-at-orange avatar Feb 23 '24 08:02 bruno-at-orange

When using directly the MODL binary, the error is printed in the console. The problem comes from the khiops bash script:

if [[  $# -eq 0  ]]; then
    # run without parameters
    # run and save scenario and log files in directory KHIOPS_LAST_RUN_DIR
    $KHIOPS_MPI_COMMAND MODL -o "${KHIOPS_LAST_RUN_DIR}"/scenario._kh -e "${KHIOPS_LAST_RUN_DIR}"/log.txt
else
    # run with parameters
    $KHIOPS_MPI_COMMAND MODL "$@"
fi

when we launch khiops without parameter, the script add -e and -o, and then the error is printed in the default error file.

bruno-at-orange avatar May 28 '24 07:05 bruno-at-orange