Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation issue on Ubuntu 20.04 LTS #235

Closed
moldach opened this issue Aug 20, 2020 · 25 comments
Closed

Installation issue on Ubuntu 20.04 LTS #235

moldach opened this issue Aug 20, 2020 · 25 comments

Comments

@moldach
Copy link

moldach commented Aug 20, 2020

Trouble installing on Ubuntu20.04 LTS using the following:

sudo apt-get install -y default-jre
sudo apt-get install -y default-jdk
sudo R CMD javareconf

followed by opening R and install.packages("rJava").

The log:

(base) mtg@mtg-ThinkPad-P53:~$ sudo apt-get install default-jre
Reading package lists... Done
Building dependency tree       
Reading state information... Done
default-jre is already the newest version (2:1.11-72).
The following packages were automatically installed and are no longer required:
  kwayland-data liba52-0.7.4 libaribb24-0 libbasicusageenvironment1 libcddb2 libdouble-conversion3
  libdvbpsi10 libebml4v5 libfam0 libfdk-aac1 libfprint-2-tod1 libgroupsock8 libhfstospell10
  libixml10 libkf5auth-data libkf5bookmarks-data libkf5codecs-data libkf5completion-data
  libkf5config-data libkf5configwidgets-data libkf5coreaddons-data libkf5dbusaddons-data
  libkf5declarative-data libkf5dnssd-data libkf5globalaccel-data libkf5i18n-data
  libkf5iconthemes-data libkf5itemviews-data libkf5jobwidgets-data libkf5kcmutils-data
  libkf5notifications-data libkf5notifyconfig-data libkf5package-data libkf5parts-data
  libkf5service-data libkf5solid5-data libkf5sonnet5-data libkf5textwidgets-data libkf5wallet-data
  libkf5widgetsaddons-data libkf5windowsystem-data libkf5xmlgui-data liblivemedia77 libllvm9
  libmad0 libmatroska6v5 libmbedcrypto3 libmbedtls12 libmbedx509-0 libmpeg2-4 libopenmpt-modplug1
  libphonon4qt5-data libplacebo7 libproxy-tools libresid-builder0c2a libsdl-image1.2
  libsdl-ttf2.0-0 libsdl1.2debian libsidplay2 libspatialaudio0 libssh2-1 libupnp13
  libusageenvironment3 libva-wayland2 libvlc-bin libvlc5 libvlccore9 libvoikko1 libxcb-xinerama0
  libxcb-xinput0 python3-click python3-colorama qtcore4-l10n qttranslations5-l10n vlc-data
  vlc-plugin-base vlc-plugin-video-output
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 47 not upgraded.
(base) mtg@mtg-ThinkPad-P53:~$ sudo apt-get install default-jre
Reading package lists... Done
Building dependency tree       
Reading state information... Done
default-jre is already the newest version (2:1.11-72).
The following packages were automatically installed and are no longer required:
  kwayland-data liba52-0.7.4 libaribb24-0 libbasicusageenvironment1 libcddb2 libdouble-conversion3
  libdvbpsi10 libebml4v5 libfam0 libfdk-aac1 libfprint-2-tod1 libgroupsock8 libhfstospell10
  libixml10 libkf5auth-data libkf5bookmarks-data libkf5codecs-data libkf5completion-data
  libkf5config-data libkf5configwidgets-data libkf5coreaddons-data libkf5dbusaddons-data
  libkf5declarative-data libkf5dnssd-data libkf5globalaccel-data libkf5i18n-data
  libkf5iconthemes-data libkf5itemviews-data libkf5jobwidgets-data libkf5kcmutils-data
  libkf5notifications-data libkf5notifyconfig-data libkf5package-data libkf5parts-data
  libkf5service-data libkf5solid5-data libkf5sonnet5-data libkf5textwidgets-data libkf5wallet-data
  libkf5widgetsaddons-data libkf5windowsystem-data libkf5xmlgui-data liblivemedia77 libllvm9
  libmad0 libmatroska6v5 libmbedcrypto3 libmbedtls12 libmbedx509-0 libmpeg2-4 libopenmpt-modplug1
  libphonon4qt5-data libplacebo7 libproxy-tools libresid-builder0c2a libsdl-image1.2
  libsdl-ttf2.0-0 libsdl1.2debian libsidplay2 libspatialaudio0 libssh2-1 libupnp13
  libusageenvironment3 libva-wayland2 libvlc-bin libvlc5 libvlccore9 libvoikko1 libxcb-xinerama0
  libxcb-xinput0 python3-click python3-colorama qtcore4-l10n qttranslations5-l10n vlc-data
  vlc-plugin-base vlc-plugin-video-output
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 47 not upgraded.
(base) mtg@mtg-ThinkPad-P53:~$ sudo apt-get install default-jdk
Reading package lists... Done
Building dependency tree       
Reading state information... Done
default-jdk is already the newest version (2:1.11-72).
The following packages were automatically installed and are no longer required:
  kwayland-data liba52-0.7.4 libaribb24-0 libbasicusageenvironment1 libcddb2 libdouble-conversion3
  libdvbpsi10 libebml4v5 libfam0 libfdk-aac1 libfprint-2-tod1 libgroupsock8 libhfstospell10
  libixml10 libkf5auth-data libkf5bookmarks-data libkf5codecs-data libkf5completion-data
  libkf5config-data libkf5configwidgets-data libkf5coreaddons-data libkf5dbusaddons-data
  libkf5declarative-data libkf5dnssd-data libkf5globalaccel-data libkf5i18n-data
  libkf5iconthemes-data libkf5itemviews-data libkf5jobwidgets-data libkf5kcmutils-data
  libkf5notifications-data libkf5notifyconfig-data libkf5package-data libkf5parts-data
  libkf5service-data libkf5solid5-data libkf5sonnet5-data libkf5textwidgets-data libkf5wallet-data
  libkf5widgetsaddons-data libkf5windowsystem-data libkf5xmlgui-data liblivemedia77 libllvm9
  libmad0 libmatroska6v5 libmbedcrypto3 libmbedtls12 libmbedx509-0 libmpeg2-4 libopenmpt-modplug1
  libphonon4qt5-data libplacebo7 libproxy-tools libresid-builder0c2a libsdl-image1.2
  libsdl-ttf2.0-0 libsdl1.2debian libsidplay2 libspatialaudio0 libssh2-1 libupnp13
  libusageenvironment3 libva-wayland2 libvlc-bin libvlc5 libvlccore9 libvoikko1 libxcb-xinerama0
  libxcb-xinput0 python3-click python3-colorama qtcore4-l10n qttranslations5-l10n vlc-data
  vlc-plugin-base vlc-plugin-video-output
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 47 not upgraded.
(base) mtg@mtg-ThinkPad-P53:~$ sudo R CMD javareconf
*** JAVA_HOME is not a valid path, ignoring
Java interpreter : /usr/bin/java
Java version     : 11.0.8
Java home path   : /usr/lib/jvm/java-11-openjdk-amd64
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/server -ljvm
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-5iUtQS/r-base-4.0.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o conftest.so conftest.o -L/usr/lib/jvm/java-11-openjdk-amd64/lib/server -ljvm -L/usr/lib/R/lib -lR


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

(base) mtg@mtg-ThinkPad-P53:~$ R

R version 4.0.2 (2020-06-22) -- "Taking Off Again"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages("rJava")
Installing package into ‘/home/mtg/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/rJava_0.9-13.tar.gz'
Content type 'application/x-gzip' length 664898 bytes (649 KB)
==================================================
downloaded 649 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... /home/mtg/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cpp
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/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/bin/java'
archiver    : '/usr/bin/jar'
compiler    : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : '-I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux'
java libs   : '-L/usr/lib/jvm/java-11-openjdk-amd64/lib/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... configure: error: Cannot compile a simple JNI program. See config.log for details.

Make sure you have Java Development Kit installed and correctly registered in R.
If in doubt, re-run "R CMD javareconf" as root.

ERROR: configuration failed for package ‘rJava’
* removing ‘/home/mtg/R/x86_64-pc-linux-gnu-library/4.0/rJava’
* restoring previous ‘/home/mtg/R/x86_64-pc-linux-gnu-library/4.0/rJava’

The downloaded source packages are in
	‘/tmp/Rtmp43nobC/downloaded_packages’
Warning message:
In install.packages("rJava") :
  installation of package ‘rJava’ had non-zero exit status

SystemInfo()

(base) mtg@mtg-ThinkPad-P53:~$ cat /proc/version
Linux version 5.4.0-42-generic (buildd@lgw01-amd64-038) (gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2)) #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020
(base) mtg@mtg-ThinkPad-P53:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.1 LTS
Release:	20.04
Codename:	focal

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3

locale:
 [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_CA.UTF-8        LC_COLLATE=en_CA.UTF-8    
 [5] LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8   
 [7] LC_PAPER=en_CA.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.2 tools_4.0.2

The use of install.packages("rJava",,"http://rforge.net") also errors.

@moldach
Copy link
Author

moldach commented Aug 20, 2020

I've also just tried with the newest version of R and am met with the same error:

(base) mtg@mtg-ThinkPad-P53:~$ R --version
R version 4.0.2 (2020-06-22) -- "Taking Off Again"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

@eddelbuettel
Copy link

eddelbuettel commented Aug 20, 2020

What's wrong with apt-get ?

edd@rob:~$ docker run --rm -ti rocker/r-bspm:20.04 bash       # ignore the sub-container; it is "just" Ubuntu 20.04 under it                                           
root@3a1364ea3417:/# apt update >/dev/null 2>&1                                                          
root@3a1364ea3417:/# apt install r-cran-rjava 
[.... copious output removed ...]
root@3a1364ea3417:/# R 

R version 4.0.2 (2020-06-22) -- "Taking Off Again"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Loading required package: utils
> library(rJava)
> 

@s-u
Copy link
Owner

s-u commented Aug 20, 2020

@moldach please have a look at config.log - it will tell you what went wrong.

@moldach
Copy link
Author

moldach commented Aug 20, 2020

I followed advice from this post which suggested:

R CMD javareconf -e

this worked for me.

@s-u
Copy link
Owner

s-u commented Aug 20, 2020

It means your root environment is different from your user environment (PATH most likely) so when you ran sudo it wasn't picking up what you thought it would.

@moldach
Copy link
Author

moldach commented Aug 20, 2020

Hi @s-u thank you for clearing that up.

Is this a_bad_ thing to have my root different from my user environment?

And if so any suggestions on how to fix/better-set-up?

Thanks,

(base) mtg@mtg-ThinkPad-P53:~$ echo $PATH
/home/mtg/perl5/bin:/home/mtg/bin/root/bin:/home/mtg/bin/samtools-1.10:/home/mtg/.pyenv/shims:/home/mtg/.pyenv/bin:/home/mtg/.pyenv/versions/:/home/mtg/bin/vcftools_0.1.13/bin:/home/mtg/bin/vg-v1.24.0:/home/mtg/.local/bin:/home/mtg/bin/GenESysV:/home/mtg/anaconda3/bin:/home/mtg/anaconda3/condabin:/home/mtg/.local/bin:/home/mtg/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

@s-u
Copy link
Owner

s-u commented Aug 20, 2020

It's not bad in general, but if it pick up something wrong it won't work - e.g. on some systems the user has full JDK on PATH while the system has only incomplete stubs. Like I said, the only way to find out is to look at config.log.

@moldach
Copy link
Author

moldach commented Aug 20, 2020

Sorry but where do you think I could find this config.log file?

I've tried searching but cannot seem to find it...

(base) mtg@mtg-ThinkPad-P53:~$ find . -name "config.log"
./bin/root/AFTERIMAGE-prefix/src/AFTERIMAGE/config.log
./bin/samtools-1.10/htslib-1.10/config.log
./bin/samtools-1.10/config.log
./bin/htslib-1.10.2/config.log
./projects/TEST-MOMIG/gfalint/config.log
./Python-3.5.0/build/temp.linux-x86_64-3.5/libffi/config.log
./Python-3.5.0/config.log

@moldach
Copy link
Author

moldach commented Aug 20, 2020

The problem I'm facing with this root environment versus user environment is that now I have rJava installed and can access from the terminal; however, I cannot access it from RStudio

@eddelbuettel
Copy link

It is actually correct that the r-cran-rjava in the distro still depends on the older R it was built with. So while @moldach moved ahead and got a new R binary (via a .deb) he failed to also add a repo for the thousands of R binaries.

From the same Docker container:

root@c4113c846e7e:/# apt-cache policy r-cran-rjava
r-cran-rjava:
  Installed: (none)
  Candidate: 0.9-13-1cran1.2004.0
  Version table:
     0.9-13-1cran1.2004.0 500
        500 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal/main amd64 Packages
     0.9-11-2 500
        500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
root@c4113c846e7e:/# 

This is not tied to Docker. You want the c2d4u.team/c2d4u4.0+ repo when you run R 4.0.2 (as you should). That is all. It will pull in a binary with its matching Java SDK.

@moldach
Copy link
Author

moldach commented Aug 20, 2020

Following @eddelbuettel still get errors:

(base) mtg@mtg-ThinkPad-P53:~/CVLs/ensembl-comparison$ sudo apt-cache policy r-cran-rjava
r-cran-rjava:
  Installed: (none)
  Candidate: 0.9-11-2
  Version table:
     0.9-11-2 500
        500 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages

(base) mtg@mtg-ThinkPad-P53:~/CVLs/ensembl-comparison$ sudo apt 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 resolve the situation:

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

Any idea how to solve this @s-u ?

@eddelbuettel
Copy link

eddelbuettel commented Aug 20, 2020

You did not read what I wrote. Your apt only knows about the outdated r-cran-rjava that will not work with the newer R binary you choose to install.

This is entirely between and you and your system. @s-u has nothing to do with this. As I wrote

  • add the appropriate PPA
  • run apt update
  • run the above command again, you should now see two different versions of r-cran-rjava
  • the newer one will be picked and work

@moldach
Copy link
Author

moldach commented Aug 20, 2020

You did not read what I wrote. Your apt only knows about the outdated r-cran-rjava As I wrote

Sorry things are not working out, perhaps I'm not choosing the appropriate PPA?

  • add the appropriate PPA
sudo add-apt-repository -r ppa:marutter/rrutter3.5 
* run `apt update`
(base) mtg@mtg-ThinkPad-P53:~/CVLs/ensembl-comparison$ sudo apt update
Hit:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://security.debian.org/debian-security jessie/updates InRelease
Hit:3 https://dl.yarnpkg.com/debian stable InRelease
Ign:4 http://ppa.launchpad.net/marutter/c2d4u3.5/ubuntu focal InRelease
Hit:5 http://archive.ubuntu.com/ubuntu focal InRelease
Get:6 http://archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB]
Hit:7 http://ppa.launchpad.net/remmina-ppa-team/remmina-next/ubuntu focal InRelease
Hit:8 https://packages.microsoft.com/repos/ms-teams stable InRelease
Get:9 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Err:10 http://ppa.launchpad.net/marutter/c2d4u3.5/ubuntu focal Release
  404  Not Found [IP: 2001:67c:1560:8008::15 80]
Hit:11 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ InRelease
Get:12 http://archive.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Hit:13 https://cloud.r-project.org/bin/linux/ubuntu eoan-cran35/ InRelease
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/marutter/c2d4u3.5/ubuntufocal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
  • run the above command again, you should now see two different versions of r-cran-rjava

  • the newer one will be picked and work

(base) mtg@mtg-ThinkPad-P53:~/CVLs/ensembl-comparison$ sudo apt 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 resolve the situation:

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

@eddelbuettel
Copy link

eddelbuettel commented Aug 20, 2020

Do you see the line:

http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu

Do you understand that that is the repo you need to add?

Do you understand that add-apt-repository -r ppa:marutter/rrutter3.5 adds a different repo?

As I mentioned to you before here or on Twitter DM, it is all explained in this README.md. Pay particular attention to the last paragraph in the header before Installation.

(Link edited)

@moldach
Copy link
Author

moldach commented Aug 20, 2020

The link was broken in your last post, here is the link: https://cloud.r-project.org/bin/linux/ubuntu/README.html

So there is c2d4u, cd24u3.5 and c2d4u4.0+ which I guess why I was confused because it gives this error about r-api-3.5. However, since I'm using R version 4.0.2 I should do the following:

$ sudo add-apt-repository ppa:c2d4u.team/c2d4u4.0+
$ sudo apt-get update
$ sudo apt install r-cran-rjava

(base) mtg@mtg-ThinkPad-P53:~/CVLs/ensembl-comparison$ sudo apt install r-cran-rjava
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  r-cran-rjava
0 upgraded, 1 newly installed, 0 to remove and 46 not upgraded.
Need to get 689 kB of archives.
After this operation, 1,900 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu focal/main amd64 r-cran-rjava amd64 0.9-13-1cran1.2004.0 [689 kB]
Fetched 689 kB in 2s (333 kB/s)
Selecting previously unselected package r-cran-rjava.
(Reading database ... 290065 files and directories currently installed.)
Preparing to unpack .../r-cran-rjava_0.9-13-1cran1.2004.0_amd64.deb ...
Unpacking r-cran-rjava (0.9-13-1cran1.2004.0) ...
Setting up r-cran-rjava (0.9-13-1cran1.2004.0) ...

Looks like it installed...

Open R and check:

> library(rJava)
Error: package or namespace load failed for ‘rJava’:
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/home/mtg/R/x86_64-pc-linux-gnu-library/4.0/rJava/libs/rJava.so':
  libjvm.so: cannot open shared object file: No such file or directory

?

@eddelbuettel
Copy link

eddelbuettel commented Aug 20, 2020

You need to also understand your .libPaths(). You also chose to have a local installation. That comes first. Just look at the error message:

'/home/mtg/R/x86_64-pc-linux-gnu-library/4.0/rJava/libs/rJava.so'

Your path, not the system. So after all these messages you actually do have the working rJava installed. But you also still have a broken one, and R will always try in order. So it tries the broken one first, and you are still frustrated.

@s-u
Copy link
Owner

s-u commented Nov 4, 2020

I'm closing this since it seems to veer of-topic and the standard installation even from sources works just fine on Ubuntu 20.04 LTS:

sudo apt-get install -y default-jdk r-base-dev
sudo R CMD javareconf
sudo R -e 'install.packages("rJava",,"https://cloud.r-project.org")'

$ R --quiet -e 'library(rJava); .jinit(); J("java.lang.System")$getProperty("java.version")'
> library(rJava); .jinit(); J("java.lang.System")$getProperty("java.version")
[1] "11.0.9"

@s-u s-u closed this as completed Nov 4, 2020
@eddelbuettel
Copy link

Sure, no surprise it works find on Ubuntu 20.04 -- it has been a package inside Debian (and Ubuntu) since version 0.6.0 in 2008. If you have what the package Build-Depends: prescribe it is virtually guaranteed to work. Just how it works at CRAN. Random mixing and matching does not ....

@moldach
Copy link
Author

moldach commented Dec 6, 2020

I'm closing this since it ... works just fine on Ubuntu 20.04 LTS:

Following your instructions @s-u , it does not work fine on Ubuntu...

Ubuntu 20.04 LTS

(base) mtg@mtg-ThinkPad-P53:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.1 LTS
Release:	20.04
Codename:	focal
(base) mtg@mtg-ThinkPad-P53:~$ 

Following installations instructions

$ sudo apt-get install -y default-jdk r-base-dev
[sudo] password for mtg: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
default-jdk is already the newest version (2:1.11-72).
r-base-dev is already the newest version (4.0.3-1.2004.0).
The following packages were automatically installed and are no longer required:
  libmad0 libmikmod3 libportmidi0 libsdl-image1.2 libsdl-mixer1.2 libsdl-ttf2.0-0 python3-click
  python3-colorama python3-polib python3-pygame singularity-music ttf-dejavu-core
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
$ sudo R CMD javareconf
*** JAVA_HOME is not a valid path, ignoring
Java interpreter : /usr/bin/java
Java version     : 11.0.9.1
Java home path   : /usr/lib/jvm/java-11-openjdk-amd64
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/server -ljvm
gcc -std=gnu99 -I"/usr/share/R/include" -DNDEBUG -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-8T8CYO/r-base-4.0.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o conftest.so conftest.o -L/usr/lib/jvm/java-11-openjdk-amd64/lib/server -ljvm -L/usr/lib/R/lib -lR


JAVA_HOME        : /usr/lib/jvm/java-11-openjdk-amd64
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /usr/lib/R
Done.
$ sudo R -e 'install.packages("rJava",,"https://cloud.r-project.org")'

R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages("rJava",,"https://cloud.r-project.org")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/rJava_0.9-13.tar.gz'
Content type 'application/x-gzip' length 664898 bytes (649 KB)
==================================================
downloaded 649 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... /usr/bin/grep
checking for egrep... /usr/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/bin/java'
archiver    : '/usr/bin/jar'
compiler    : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : '-I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux'
java libs   : '-L/usr/lib/jvm/java-11-openjdk-amd64/lib/server -ljvm'
sed: -e expression #1, char 15: unterminated `s' command
sed: -e expression #1, char 15: unterminated `s' command
sed: -e expression #1, char 15: unterminated `s' command
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... configure: error: Cannot compile a simple JNI program. See config.log for details.

Make sure you have Java Development Kit installed and correctly registered in R.
If in doubt, re-run "R CMD javareconf" as root.

ERROR: configuration failed for package ‘rJava’
* removing ‘/usr/local/lib/R/site-library/rJava’
* restoring previous ‘/usr/local/lib/R/site-library/rJava’

The downloaded source packages are in
	‘/tmp/Rtmpi1UP2I/downloaded_packages’
Warning message:
In install.packages("rJava", , "https://cloud.r-project.org") :
  installation of package ‘rJava’ had non-zero exit status
> 
> 

Error

$ R --quiet -e 'library(rJava); .jinit(); J("java.lang.System")$getProperty("java.version")'
> library(rJava); .jinit(); J("java.lang.System")$getProperty("java.version")
Error: package or namespace load failed for ‘rJava’:
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/usr/local/lib/R/site-library/rJava/libs/rJava.so':
  libjvm.so: cannot open shared object file: No such file or directory
Execution halted

@moldach
Copy link
Author

moldach commented Dec 6, 2020

Sure, no surprise it works find on Ubuntu 20.04 -- it has been a package inside Debian (and Ubuntu) since version 0.6.0 in 2008. If you have what the package Build-Depends: prescribe it is virtually guaranteed to work. Just how it works at CRAN.

So what is surprising is that it does not work out-of-the-box with Ubuntu 20.04.
Is it not? What is preventing this from working?

Random mixing and matching does not ....
&
You need to also understand your .libPaths(). You also chose to have a local installation. That comes first. Just look at the error message:

'/home/mtg/R/x86_64-pc-linux-gnu-library/4.0/rJava/libs/rJava.so'

Your path, not the system. So after all these messages you actually do have the working rJava installed. But you also still have a broken one, and R will always try in order. So it tries the broken one first, and you are still frustrated.

Yes, I am still frustrated.
You suggested that this is a .libPaths() issue??

(base) mtg@mtg-ThinkPad-P53:~$ R

R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> .libPaths()
[1] "/home/mtg/R/x86_64-pc-linux-gnu-library/4.0"
[2] "/usr/local/lib/R/site-library"              
[3] "/usr/lib/R/site-library"                    
[4] "/usr/lib/R/library"  
  • Where is it looking for rJava
  • Where is rJava actually with the commands I followed from @s-u ?
  • How do I fix this so I can use rJava?

@eddelbuettel
Copy link

eddelbuettel commented Dec 6, 2020

Just do

sudo apt install r-cran-rjava

I have maintained the package as a binary in the Debian (and Ubuntu) distributions since about 2008 precisely because the installation is not always trivial.

PS We just had an somewhat extended discussion about installing a package from the (binary) distribution (here Ubuntu 20.04) versus from the contributed PPA (c2d4u4+) when something is only in the former (and wants r-api-3.5). That was an oversight by Michael and has been fixed; you may find the thread and explanations helpful (and it is so far the only thread in the month; the list is pretty quiet but very valuable).

@s-u
Copy link
Owner

s-u commented Dec 6, 2020

@moldach Please read the output:

*** JAVA_HOME is not a valid path, ignoring

you have broken your JAVA_HOME setting so don't expect anything to work...

@moldach
Copy link
Author

moldach commented Dec 7, 2020

Hi @eddelbuettel

Okay so I have the newest distribution:

$ sudo apt install -f r-cran-rjava
Reading package lists... Done
Building dependency tree
Reading state information... Done
r-cran-rjava is already the newest version (0.9-13-1cran1.2004.0).
The following packages were automatically installed and are no longer required:
  libmad0 libmikmod3 libportmidi0 libsdl-image1.2 libsdl-mixer1.2 libsdl-ttf2.0-0 python3-click python3-colorama python3-polib python3-pygame singularity-music ttf-dejavu-core
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Hi @s-u, do you have suggestions for how to fix JAVA_HOME settings?
I thought that sudo R CMD javareconf was supposed to do that but apparently I'm clueless.

This SE post suggested:

$ which java
/usr/bin/java
$ export JAVA_HOME=/usr/bin/java
$ sudo R CMD javareconf
...

But I get the same errors. Not sure what to do to fix this.

@eddelbuettel
Copy link

eddelbuettel commented Dec 7, 2020

  1. What is your question? If you have rJava working, how else can we help you? Now library(rJava) should work too, unless you left a broken version in your .libPath() which may get picket up first. In which case you can simply remove the broken one.

  2. The nice bit about computer code is that it is reproducible and repeatable. I provide you with working proof of a binary, and working recipes in the debian/rules file building R itself (with proper Java on the build-machine) and then debian/rules for rJava. Those are all public, and in debian/control you see the Build-Dependencies for either. I too fought at times to get the right Java (as Debian had several over the years) but by and large the code by @s-u just works as it claims and should. There is no magic, just diligent and careful application of each build step.

@s-u
Copy link
Owner

s-u commented Dec 7, 2020

@moldach do NOT set JAVA_HOME especially if you don't know what you're doing - that post you reference did not say anything close to what you did. The purpose of JAVA_HOME is to override the system defaults in special cases (e.g. where you may have multiple Java installations and you want to pick them by hand). Also if you set it, is has to be the home of the Java installation so from your output it looks like that would be /usr/lib/jvm/java-11-openjdk-amd64, but I strongly caution against setting it unless you have a very good reason to do so.

That said, I don't think that's necessarily the main point. My guess would be that you're missing some libraries needed for R - I bet you didn't use the steps I sent as they are known to work. If you did, this is what you would see:
https://gist.github.com/s-u/7fb617ccb938f50d00d655ca8b57f377
So you probably have to find out what you're missing.

But first back to Dirk's point - since you finally installed the rJava binary, why don't you just use it? It also works out of the box without the need to do anything (not even use javareconf) - on clean Ubuntu:

ubuntu@dev1:~$ sudo apt install -y r-cran-rjava
[...]
ubuntu@dev1:~$ R --quiet -e 'library(rJava); .jinit(); J("java.lang.System")$getProperty("java.version")'
> library(rJava); .jinit(); J("java.lang.System")$getProperty("java.version")
[1] "11.0.9.1"

If you have some broken one in there, just make sure you remove it - that's why he told you to check your .libPaths() and check for any copies there except for the system one which is in:

> system.file(package="rJava")
[1] "/usr/lib/R/site-library/rJava"

But make sure you have not messed up your R in the first place by hand - if in doubt, purge R and packages and re-install. If you modified the R Java settings and broke it, it will be harder to fix since the system assumes you know what you're doing and won't override your manual changes unless instructed to do so (Dirk may be the expert on that one).

Please do NOT mix the two approaches, installing binary rJava (r-cran-java) only uses JRE and so you will NOT have the tools to compile rJava from sources, you need the full JDK for that.

If you want to check what goes wrong, the easiest is to install rJava from a local directory so config.log is kept and you can look at it:

Rscript -e 'download.packages("rJava",".",,"http://cloud.R-project.org")'
tar fxz rJava_0.9-13.tar.gz 
R CMD INSTALL rJava

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants