error installing packages

Guys, I have a problem installing packages. When I try to install, any package appears this warning, and then the installation is not done.
It happens for any package.

PS: I use Ubuntu 18.04. On Windows I do not have this problem, only on Ubuntu.
Thank you!

The warning is as follows:

Warning in install.packages:
installation of package 'xlsx' had non-zero exit status

The downloaded source packages are in
'/ Tmp / RtmpGxN5yu / downloaded_packages'

I’m afraid it’s impossible to say what’s going on here without more information. There should be several lines of console output before the two lines that you included (which just tell you that installation failed and where R put the files it tried to install). The earlier lines of output are the ones that will contain the clues to what’s going wrong.

Can you supply the complete console output from a package installation attempt?

1 Like

install.packages("xlsx")
Installing package into ‘/home/leonardo/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependencies ‘rJava’, ‘xlsxjars’

tentando a URL 'https://cloud.r-project.org/src/contrib/rJava_0.9-9.tar.gz'
Content type 'application/x-gzip' length 660454 bytes (644 KB)

downloaded 644 KB

tentando a URL 'https://cloud.r-project.org/src/contrib/xlsxjars_0.6.1.tar.gz'
Content type 'application/x-gzip' length 9477071 bytes (9.0 MB)

downloaded 9.0 MB

tentando a URL 'https://cloud.r-project.org/src/contrib/xlsx_0.5.7.tar.gz'
Content type 'application/x-gzip' length 312839 bytes (305 KB)

downloaded 305 KB

  • installing source package ‘rJava’ ...
    ** package ‘rJava’ successfully unpacked and MD5 sums checked
    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/lib/jvm/default-java/bin/jar'
    compiler : '/usr/lib/jvm/default-java/bin/javac'
    header prep.: ''
    cpp flags : '-I/usr/lib/jvm/default-java/include -I/usr/lib/jvm/default-java/include/linux'
    java libs : '-L/usr/lib/jvm/default-java/lib/server -ljvm'
    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/leonardo/R/x86_64-pc-linux-gnu-library/3.4/rJava’
    Warning in install.packages :
    installation of package ‘rJava’ had non-zero exit status
    ERROR: dependency ‘rJava’ is not available for package ‘xlsxjars’
  • removing ‘/home/leonardo/R/x86_64-pc-linux-gnu-library/3.4/xlsxjars’
    Warning in install.packages :
    installation of package ‘xlsxjars’ had non-zero exit status
    ERROR: dependencies ‘rJava’, ‘xlsxjars’ are not available for package ‘xlsx’
  • removing ‘/home/leonardo/R/x86_64-pc-linux-gnu-library/3.4/xlsx’
    Warning in install.packages :
    installation of package ‘xlsx’ had non-zero exit status

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

Thanks, that helps a lot! xslx depends on rJava, and it’s the rJava installation that failed. You can see that in this part of the log:

So I’m afraid you you need to fix the issues with your Java configuration before you can install rJava, and therefore before you can install xslx.

Before you dive into that, though, I’d take a look and see if the readxl package can meet your needs (maybe along with some of the related packages for writing Excel files discussed at the end of the linked page). A major benefit is that it has no Java dependency, so you don’t have to struggle with stuff like this!

Originally, you said:

Are there other packages that are failing to install, or was it just xslx?

1 Like

I'm going to test readxl. Thank you.

I tried to install 3 packages.
1 - DPLYR
2 - STRINGR
3 - RIO

The problem is that when I send install the sensation is that it has entered an infinite looping, it takes a lot. (very much).Totally unlike windows. But I think it's just a lack of patience on my part. I have not gotten used to Linux yet. Yes I am trying to migrate to Linux but I think it is not working very well. haha

Installing packages can take a lot longer than you might be used to if more of the packages (and their many dependencies) have to be compiled from source (before, on Windows, you may have frequently been installing from pre-compiled binaries). If you're seeing a lot of console logs scroll by with references to gcc or clang, for instance, then yeah, I'd just give it more time — some package has C code that needs to be compiled.

You need to install java for your Ubuntu system first.

3 Likes