невозможно установить зависимость rJava на сервере Ubuntu - PullRequest
6 голосов
/ 01 июля 2019

Я пытаюсь установить некоторые пакеты (mailR), чтобы иметь возможность сообщать об ошибках и сообщения своим пользователям по почте и подключаться к серверу HIVE через rJdbc, но установка зависимости rJava становится все более запутанной по мере выполнения шагов.

Первая ошибка запрашивает пакет rJava, поэтому я попытался установить rJava:

install.packages("rJava")

Installing package into ‘/home/joe/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/rJava_0.9-11.tar.gz'
Content type 'application/x-gzip' length 675188 bytes (659 KB)
==================================================
downloaded 659 KB

* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... gcc -std=gnu99
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 -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -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 -std=gnu99 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/lib/jvm/default-java/bin/java'
archiver    : '/usr/bin/jar'
compiler    : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : ''
java libs   : ''
configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.

If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.

ERROR: configuration failed for package ‘rJava’
* removing ‘/home/jmvo/R/x86_64-pc-linux-gnu-library/3.6/rJava’
Warning in install.packages :
  installation of package ‘rJava’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpkTvmz8/downloaded_packages’

Поэтому я следовал инструкциям от имени пользователя root и:

sudo R CMD javareconf

Java interpreter : /usr/lib/jvm/default-java/bin/java
Java version     : 11.0.3
Java home path   : /usr/lib/jvm/default-java
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    : 
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-VAQCff/r-base-3.6.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c conftest.c -o conftest.o
conftest.c:1:10: fatal error: jni.h: No such file or directory
 #include <jni.h>
          ^~~~~~~
compilation terminated.
/usr/lib/R/etc/Makeconf:167: recipe for target 'conftest.o' failed
make: *** [conftest.o] Error 1
Unable to compile a JNI program


JAVA_HOME        : /usr/lib/jvm/default-java
Java library path: 
JNI cpp flags    : 
JNI linker flags : 
Updating Java configuration in /usr/lib/R
Done.

Я проверилесли у меня установлен Open JDK, потому что многие ответы SO, по-видимому, связаны с отсутствием JDK.

 java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.04.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)

, чтобы быть уверенным, попробуйте установить JDK снова с

sudo apt-get install openjdk-8-jdk                                                
Reading package lists... Done
Building dependency tree       
Reading state information... Done
openjdk-8-jdk is already the newest version (8u212-b03-0ubuntu1.18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 74 not upgraded.

Некоторые другие ответы SOпредложите установить rJava через apt-get следующим образом

 sudo apt-get install r-cran-rjava

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 r-cran-rjava : Depends: r-api-3.4
E: Unable to correct problems, you have held broken packages.o 

Но я использую R 3.6, поэтому возвращаться назад не вариант.Переход на Oracle Java не вариант.Многие рабочие приложения зависят от OpenJDK.

Пока успехов нет.Это бесконечный процесс.Пробовал много SO ответов по этому вопросу безрезультатно.Мне нужна rJava не только для почты, но и для многих других процессов, таких как подключение к Hive и т. Д. Из R.

Спасибо

...