Error building rJava when deploying shiny app

  1. Received the below output in my deploy window, within RStudio, trying to re-deploy an update to an existing app on shinyappsio.
  2. This only happens with Package Cache turned OFF --
  3. The app will deploy only with Package Cache turned on, which suggests it's using older builds of the packages.
  4. The app has successfully deployed in the past, and we have re-deployed several dozen times by this point.
  5. App can run locally without issue.

################################ Begin Task Log ################################
[2020-05-11T22:30:05.320615561+0000] Execute script: packages/build/rJava.sh

  • set -e
  • /usr/bin/R CMD javareconf
    Java interpreter : /usr/bin/java
    Java version : 1.8.0_252
    Java home path : /usr/lib/jvm/java-8-openjdk-amd64/jre
    Java compiler : /usr/bin/javac
    Java headers gen.: /usr/bin/javah
    Java archive tool: /usr/bin/jar

trying to compile and link a JNI program
detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
gcc -I"/opt/R/3.6.1/lib/R/include" -DNDEBUG -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/usr/local/include -fpic -g -O2 -c conftest.c -o conftest.o
gcc -shared -L/opt/R/3.6.1/lib/R/lib -L/usr/local/lib -o conftest.so conftest.o -L/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server -ljvm -L/opt/R/3.6.1/lib/R/lib -lR

JAVA_HOME : /usr/lib/jvm/java-8-openjdk-amd64/jre
Java library path: (JAVA_HOME)/lib/amd64/server JNI cpp flags : -I(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
Updating Java configuration in /opt/R/3.6.1/lib/R
Done.

[2020-05-11T22:30:06.272047846+0000] Execute script: packages/build/sys.sh

  • set -e
  • apt-get update -qq
  • apt-get install -y libapparmor-dev
    Reading package lists...
    Building dependency tree...
    Reading state information...
    The following NEW packages will be installed:
    libapparmor-dev
    0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
    Need to get 67.8 kB of archives.
    After this operation, 229 kB of additional disk space will be used.
    Get:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libapparmor-dev amd64 2.10.95-0ubuntu2.11 [67.8 kB]
    debconf: delaying package configuration, since apt-utils is not installed
    Fetched 67.8 kB in 0s (0 B/s)
    Selecting previously unselected package libapparmor-dev:amd64.
    (Reading database ... 120977 files and directories currently installed.)
    Preparing to unpack .../libapparmor-dev_2.10.95-0ubuntu2.11_amd64.deb ...
    Unpacking libapparmor-dev:amd64 (2.10.95-0ubuntu2.11) ...
    Processing triggers for man-db (2.7.5-1) ...
    Setting up libapparmor-dev:amd64 (2.10.95-0ubuntu2.11) ...
    [2020-05-11T22:30:11.530125907+0000] Building R package: viridisLite (0.3.0)
    /mnt/packages/build /mnt
  • installing to library ‘/opt/R/3.6.1/lib/R/library’
  • installing source package ‘viridisLite’ ...
    ** package ‘viridisLite’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** R
    ** data
    *** moving datasets to lazyload DB
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    *** copying figures
    ** building package indices
    ** testing if installed package can be loaded from temporary location
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path
  • creating tarball
    packaged installation of ‘viridisLite’ as ‘viridisLite_0.3.0_R_x86_64-pc-linux-gnu.tar.gz’
  • DONE (viridisLite)
    /mnt
    [2020-05-11T22:30:13.297502403+0000] Building R package: sourcetools (0.1.7)
    /mnt/packages/build /mnt
  • installing to library ‘/opt/R/3.6.1/lib/R/library’
  • installing source package ‘sourcetools’ ...
    ** package ‘sourcetools’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** lib

g++ -std=gnu++11 -shared -L/opt/R/3.6.1/lib/R/lib -L/usr/local/lib -o stringi.so stri_brkiter.o stri_collator.o stri_common.o stri_compare.o stri_container_base.o stri_container_bytesearch.o stri_container_listint.o stri_container_listraw.o stri_container_listutf8.o stri_container_regex.o stri_container_usearch.o stri_container_utf16.o stri_container_utf8.o stri_container_utf8_indexable.o stri_encoding_conversion.o stri_encoding_detection.o stri_encoding_management.o stri_escape.o stri_exception.o stri_ICU_settings.o stri_join.o stri_length.o stri_pad.o stri_prepare_arg.o stri_random.o stri_reverse.o stri_search_class_count.o stri_search_class_detect.o stri_search_class_extract.o stri_search_class_locate.o stri_search_class_replace.o stri_search_class_split.o stri_search_class_startsendswith.o stri_search_class_subset.o stri_search_class_trim.o stri_search_common.o stri_search_coll_count.o stri_search_coll_detect.o stri_search_coll_extract.o stri_search_coll_locate.o stri_search_coll_replace.o stri_search_coll_split.o stri_search_coll_startsendswith.o stri_search_coll_subset.o stri_search_boundaries_count.o stri_search_boundaries_extract.o stri_search_boundaries_locate.o stri_search_boundaries_split.o stri_search_fixed_count.o stri_search_fixed_detect.o stri_search_fixed_extract.o stri_search_fixed_locate.o stri_search_fixed_replace.o stri_search_fixed_split.o stri_search_fixed_subset.o stri_search_fixed_startsendswith.o stri_search_in.o stri_search_other_split.o stri_search_regex_count.o stri_search_regex_detect.o stri_search_regex_extract.o stri_search_regex_locate.o stri_search_regex_match.o stri_search_regex_replace.o stri_search_regex_split.o stri_search_regex_subset.o stri_sort.o stri_stats.o stri_stringi.o stri_sub.o stri_test.o stri_time_zone.o stri_time_calendar.o stri_time_symbols.o stri_time_format.o stri_trans_casemap.o stri_trans_other.o stri_trans_normalization.o stri_trans_transliterate.o stri_ucnv.o stri_uloc.o stri_utils.o stri_wrap.o -L/usr/lib/x86_64-linux-gnu -licui18n -licuuc -licudata -L/opt/R/3.6.1/lib/R/lib -lR
make: Leaving directory '/tmp/RtmpwAmEgd/R.INSTALLc17145674/stringi/src'
make: Entering directory '/tmp/RtmpwAmEgd/R.INSTALLc17145674/stringi/src'
make: Leaving directory '/tmp/RtmpwAmEgd/R.INSTALLc17145674/stringi/src'
installing via 'install.libs.R' to /opt/R/3.6.1/lib/R/library/00LOCK-stringi/00new/stringi
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path

  • creating tarball
    packaged installation of ‘stringi’ as ‘stringi_1.4.5_R_x86_64-pc-linux-gnu.tar.gz’
  • DONE (stringi)
    /mnt
    [2020-05-11T22:30:33.748344905+0000] Building R package: rJava (0.9-12)
    /mnt/packages/build /mnt
  • installing to library ‘/opt/R/3.6.1/lib/R/library’
  • installing source package ‘rJava’ ...
    ** package ‘rJava’ successfully unpacked and MD5 sums checked
    ** using staged installation
    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... yes
    checking whether -Xrs is supported... yes
    checking whether -Xrs will be used... yes
    checking whether JVM will be loaded dynamically... no
    checking whether JNI programs can be compiled... yes
    checking whether JNI programs run... yes
    checking JNI data types... ok
    checking whether JRI should be compiled (autodetect)... yes
    checking whether debugging output should be enabled... no
    checking whether memory profiling is desired... no
    checking whether threads support is requested... no
    checking whether callbacks support is requested... no
    checking whether JNI cache support is requested... no
    checking whether headless init is enabled... no
    checking whether JRI is requested... yes
    configure: creating ./config.status
    config.status: creating src/Makevars
    config.status: creating R/zzz.R
    config.status: creating src/config.h
    === configuring in jri (/tmp/Rtmpztv6Iy/R.INSTALLc62f53a7/rJava/jri)
    configure: running /bin/bash ./configure --disable-option-checking '--prefix=/usr/local' --cache-file=/dev/null --srcdir=.
    checking build system type... x86_64-unknown-linux-gnu
    checking host system type... x86_64-unknown-linux-gnu
    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 Java version... 1.8.0_252
    checking Java compatibility version (integer)... 8
    checking whether /usr/bin/javah actually works... yes
    checking for target flags... -target 1.4 -source 1.4
    checking whether Java interpreter works... checking whether JNI programs can be compiled... yes
    checking whether JNI programs can be run... yes
    checking JNI data types... ok
    checking whether Rinterface.h exports R_CStackXXX variables... yes
    checking whether Rinterface.h exports R_SignalHandlers... yes
    configure: creating ./config.status
    config.status: creating src/Makefile
    config.status: creating Makefile
    config.status: creating run
    config.status: creating src/config.h
    ** libs
    make: Entering directory '/tmp/Rtmpztv6Iy/R.INSTALLc62f53a7/rJava/src'
    gcc -I"/opt/R/3.6.1/lib/R/include" -DNDEBUG -I. -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/usr/local/include -fpic -g -O2 -c Rglue.c -o Rglue.o
    gcc -I"/opt/R/3.6.1/lib/R/include" -DNDEBUG -I. -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/usr/local/include -fpic -g -O2 -c arrayc.c -o arrayc.o
    gcc -I"/opt/R/3.6.1/lib/R/include" -DNDEBUG -I. -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/usr/local/include -fpic -g -O2 -c callJNI.c -o callJNI.o
    gcc -I"/opt/R/3.6.1/lib/R/include" -DNDEBUG -I. -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/usr/local/include -fpic -g -O2 -c callback.c -o callback.o
    gcc -I"/opt/R/3.6.1/lib/R/include" -DNDEBUG -I. -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/usr/local/include -fpic -g -O2 -c fields.c -o fields.o
    gcc -I"/opt/R/3.6.1/lib/R/include" -DNDEBUG -I. -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/usr/local/include -fpic -g -O2 -c init.c -o init.o
    gcc -I"/opt/R/3.6.1/lib/R/include" -DNDEBUG -I. -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/usr/local/include -fpic -g -O2 -c jri_glue.c -o jri_glue.o
    gcc -I"/opt/R/3.6.1/lib/R/include" -DNDEBUG -I. -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/usr/local/include -fpic -g -O2 -c loader.c -o loader.o
    gcc -I"/opt/R/3.6.1/lib/R/include" -DNDEBUG -I. -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/usr/local/include -fpic -g -O2 -c otables.c -o otables.o
    gcc -I"/opt/R/3.6.1/lib/R/include" -DNDEBUG -I. -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/usr/local/include -fpic -g -O2 -c rJava.c -o rJava.o
    gcc -I"/opt/R/3.6.1/lib/R/include" -DNDEBUG -I. -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/usr/local/include -fpic -g -O2 -c tools.c -o tools.o
    gcc -shared -L/opt/R/3.6.1/lib/R/lib -L/usr/local/lib -o rJava.so Rglue.o arrayc.o callJNI.o callback.o fields.o init.o jri_glue.o loader.o otables.o rJava.o tools.o -L/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server -ljvm -L/opt/R/3.6.1/lib/R/lib -lR
    (cd ../jri && make)
    make[1]: Entering directory '/tmp/Rtmpztv6Iy/R.INSTALLc62f53a7/rJava/jri'
    make -C src JRI.jar
    make[2]: Entering directory '/tmp/Rtmpztv6Iy/R.INSTALLc62f53a7/rJava/jri/src'
    /usr/bin/javac -target 1.4 -source 1.4 -d . ../package-info.java ../RFactor.java ../REXP.java ../Rengine.java ../Mutex.java ../RConsoleOutputStream.java ../RMainLoopCallbacks.java ../RVector.java ../RBool.java ../RList.java
    warning: [options] bootstrap class path not set in conjunction with -source 1.4
    warning: [options] source value 1.4 is obsolete and will be removed in a future release
    warning: [options] target value 1.4 is obsolete and will be removed in a future release
    warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
    4 warnings
    if [ -n "/usr/bin/javah" ]; then /usr/bin/javah -d . -classpath . org.rosuda.JRI.Rengine; fi
    gcc -c -o Rengine.o Rengine.c -g -Iinclude -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -g -O2 -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -fpic -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/opt/R/3.6.1/lib/R/include -I/opt/R/3.6.1/lib/R/include
    gcc -c -o jri.o jri.c -g -Iinclude -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -g -O2 -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -fpic -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/opt/R/3.6.1/lib/R/include -I/opt/R/3.6.1/lib/R/include
    gcc -c -o Rcallbacks.o Rcallbacks.c -g -Iinclude -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -g -O2 -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -fpic -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -I/opt/R/3.6.1/lib/R/include -I/opt/R/3.6.1/lib/R/include
    gcc -c -o Rinit.o Rinit.c -g -Iinclude -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -g -O2 -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -fpic -I/opt/R/3.6.1/lib/R/include -I/opt/R/3.6.1/lib/R/include
    gcc -c -o globals.o globals.c -g -Iinclude -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -g -O2 -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -fpic -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux
    gcc -c -o rjava.o rjava.c -g -Iinclude -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -g -O2 -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -fpic -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux
    rjava.c: In function ‘RJava_request_lock’:
    rjava.c:22:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
    write(ipcout, buf, sizeof(ptrlong));
    ^
    rjava.c: In function ‘RJava_clear_lock’:
    rjava.c:30:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
    write(ipcout, buf, sizeof(ptrlong));
    ^
    rjava.c: In function ‘RJava_request_callback’:
    rjava.c:39:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
    write(ipcout, buf, sizeof(ptrlong) * 3);
    ^
    rjava.c: In function ‘RJava_init_ctrl’:
    rjava.c:51:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
    write(ipcout, buf, sizeof(ptrlong));
    ^
    rjava.c:52:3: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
    read(resin, buf, sizeof(ptrlong) * 2);
    ^
    gcc -o libjri.so Rengine.o jri.o Rcallbacks.o Rinit.o globals.o rjava.o -shared -L/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server -ljvm -Wl,--export-dynamic -fopenmp -L/usr/local/lib -L/opt/R/3.6.1/lib/R/lib -lR -lpcre2-8 -lpcre -llzma -lbz2 -lz -lrt -ldl -lm -licuuc -licui18n
    /usr/bin/ld: cannot find -lpcre2-8
    collect2: error: ld returned 1 exit status
    Makefile.all:35: recipe for target 'libjri.so' failed
    make[2]: *** [libjri.so] Error 1
    make[2]: Leaving directory '/tmp/Rtmpztv6Iy/R.INSTALLc62f53a7/rJava/jri/src'
    Makefile.all:19: recipe for target 'src/JRI.jar' failed
    make[1]: *** [src/JRI.jar] Error 2
    make[1]: Leaving directory '/tmp/Rtmpztv6Iy/R.INSTALLc62f53a7/rJava/jri'
    Makevars:14: recipe for target 'jri' failed
    make: *** [jri] Error 2
    make: Leaving directory '/tmp/Rtmpztv6Iy/R.INSTALLc62f53a7/rJava/src'
    make: Entering directory '/tmp/Rtmpztv6Iy/R.INSTALLc62f53a7/rJava/src'
    make: Leaving directory '/tmp/Rtmpztv6Iy/R.INSTALLc62f53a7/rJava/src'
    ERROR: compilation failed for package ‘rJava’
  • removing ‘/opt/R/3.6.1/lib/R/library/rJava’
    ################################# End Task Log #################################
    Error: Unhandled Exception: Child Task 729884075 failed: Error building image: Error building rJava (0.9-12). Build exited with non-zero status: 1
    Execution halted
5 Likes

I have heard that rJava is not a great package and often causes problems. You can see that if you google "using rJava in shiny".

I used it a while back with a package that interrogated Excel files (XLConnect), but I ended up switching to a different package (tidyxl) since rJava was causing so many problems.

thank you; someone else gave me that same advice. looking into purging it.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.