Search code examples
rrjavadock

configuration failed for package ‘rJava’ when running rize - R


I am trying to use the rize package to create a Dockerfile for ShinyApp. Starting the rize::shiny_dockerize() comand from the App dir. One of the packages which are required is the xlsx (Probably hier it is trying also to install rJava). I get the following error:

trying URL 'https://cran.rstudio.com/src/contrib/xlsxjars_0.6.1.tar.gz'
Content type 'application/x-gzip' length 9477071 bytes (9.0 MB)
==================================================
downloaded 9.0 MB

* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
configure: checking whether gcc supports static inline...
yes
checking whether setjmp.h is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
checking Java support in R... present:
interpreter : '/usr/bin/java'
archiver    : '/usr/bin/jar'
compiler    : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : '-I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux'
java libs   : '-L/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server -ljvm'
checking whether Java run-time works... ./configure: line 3766: /usr/bin/java: No such file or directory
no
configure: error: Java interpreter '/usr/bin/java' does not work
ERROR: configuration failed for package ‘rJava’
* removing ‘/usr/local/lib/R/site-library/rJava’
Error in i.p(...) :
  (converted from warning) installation of package ‘rJava’ had non-zero exit status
Calls: <Anonymous> ... with_rprofile_user -> with_envvar -> force -> force -> i.p
Execution halted
The command '/bin/sh -c R -e "setwd('/srv/shiny-server/app'); automagic::automagic()"' returned a non-zero code: 1
Error in rize::shiny_dockerize() : object 'view_app' not found

does anyone how I can bring this to work in the rize package?


Solution

  • It looks like you have issues with setting proper location of Java. Note that making R happy with Java might be a little bit of struggle.

    Take a look here: http://www.owsiak.org/r-java-11-and-making-sure-you-can-load-rjava/ for a sample. It is macOS based, but still, it should work fine.

    Basically, what you want to do is to set your JAVA_HOME such way it points at Java installation. Once it's done, you can run R cmd javareconf like this

    > sudo R CMD javareconf \
    JAVA_HOME=${JAVA_HOME} \
    JAVA=${JAVA_HOME}/bin/java \
    JAVAC=${JAVA_HOME}/bin/javac \
    JAVAH=${JAVA_HOME}/bin/javah \
    JAR=${JAVA_HOME}/bin/jar
    

    Make sure you have gcc installed and that you can compile simple C code.