oracle / fastr

A high-performance implementation of the R programming language, built on GraalVM.
Other
623 stars 64 forks source link

FastR assumes its installation directory is writable #14

Closed lucaswerkmeister closed 6 years ago

lucaswerkmeister commented 6 years ago

I published an Arch User Repository package for FastR, which installs it into /usr/lib/jvm/java-8-graal/. Apparently, FastR assumes that its installation directory is writable for logging certain errors:

$ Rscript --polyglot -e "eval.polyglot('python', 'no_such_value')"
java.nio.file.AccessDeniedException: /usr/lib/jvm/java-8-graal/jre/languages/R/fastr_errors.log
        at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
        at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
        at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
        at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
        at java.nio.file.Files.newOutputStream(Files.java:216)
        at java.nio.file.Files.newBufferedWriter(Files.java:2860)
        at com.oracle.truffle.r.runtime.RInternalError.reportError(RInternalError.java:191)
        at com.oracle.truffle.r.runtime.RInternalError.reportError(RInternalError.java:162)
        at com.oracle.truffle.r.engine.EngineRootNode.execute(EngineRootNode.java:97)
        at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callProxy(OptimizedCallTarget.java:260)
        at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callRoot(OptimizedCallTarget.java:249)
        at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:239)
        at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:224)
        at org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.call(OptimizedCallTarget.java:200)
        at com.oracle.truffle.api.vm.PolyglotContextImpl.eval(PolyglotContextImpl.java:722)
        at org.graalvm.polyglot.Context.eval(Context.java:311)
        at com.oracle.truffle.r.launcher.RCommand.readEvalPrint(RCommand.java:256)
        at com.oracle.truffle.r.launcher.RscriptCommand.execute(RscriptCommand.java:76)
        at com.oracle.truffle.r.launcher.RscriptCommand.doMain(RscriptCommand.java:164)
        at com.oracle.truffle.r.launcher.RscriptCommand.main(RscriptCommand.java:158)
        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 com.oracle.truffle.r.legacylauncher.LegacyLauncher.main(LegacyLauncher.java:38)
internal error: PException (see fastr_errors.log)

I think fastr_errors.log needs to go somewhere else… the current working directory, perhaps? (Not that that’s always writable, so an error to write the file should still be handled better, I guess…)

Note that this is not a completely fatal error: an interactive R shell returns to the prompt, and Rscript with multiple -e options will process the other expressions without error after the first one fails like this.

steve-s commented 6 years ago

Hi Lucas,

thank you for reporting this and for creating the FastR package. We'll get it fixed. The plan so far is to try current directory, user directory and then eventually FastR installation directory, plus we'll probably append PID to the file name.

steve-s commented 6 years ago

Fixed. The error file name is fastr_errors_pidXYZ.log and is saved to current working directory at the app startup, the user home directory, tmp directory, or FastR home directory whichever is writeable (in that order).

lucaswerkmeister commented 6 years ago

Great, thank you! (For the record, AFAICT the fix commit is bd11c78bf6a212f0722bde3efd64339bb663a07a.)