Cannot install packages on Ubuntu 18.04.2 LTS / "installation of package had non-zero exit status"

HI everybody,

My Uni recently switched our computers to Ubuntu, and I can't figure out how to install packages anymore on Rstudio. For exemple when trying to install lme4

install.packages('lme4')

I get the following error:


> install.packages('lme4')
Installing package into ‘/home/thomas/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependency ‘nloptr’

trying URL 'https://cloud.r-project.org/src/contrib/nloptr_1.2.2.2.tar.gz'
Content type 'application/x-gzip' length 2450931 bytes (2.3 MB)
==================================================
downloaded 2.3 MB

trying URL 'https://cloud.r-project.org/src/contrib/lme4_1.1-23.tar.gz'
Content type 'application/x-gzip' length 4137774 bytes (3.9 MB)
==================================================
downloaded 3.9 MB

* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
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 g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking for pkg-config... yes
configure: Now testing for NLopt header file.
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/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 nlopt.h usability... no
checking nlopt.h presence... no
checking for nlopt.h... no
configure: Need to configure and build NLopt
configure: Starting to install library to /tmp/RtmpyUZU19/R.INSTALL604c1767fe44/nloptr/src/nlopt_src
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
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 whether gcc -std=gnu99 understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc -std=gnu99... gcc3
checking for gcc -std=gnu99 option to accept ISO C99... none needed
checking for gcc -std=gnu99 option to accept ISO Standard C... (cached) none needed
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc -std=gnu99... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... dlltool
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ERROR: no information for variable 'RANLIB'
checking command to parse /usr/bin/nm -B output from gcc -std=gnu99 object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for ANSI C header files... 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 dlfcn.h... yes
checking for objdir... .libs
checking if gcc -std=gnu99 supports -fno-rtti -fno-exceptions... no
checking for gcc -std=gnu99 option to produce PIC... -fPIC -DPIC
checking if gcc -std=gnu99 PIC flag -fPIC -DPIC works... yes
checking if gcc -std=gnu99 static flag -static works... yes
checking if gcc -std=gnu99 supports -c -o file.o... yes
checking if gcc -std=gnu99 supports -c -o file.o... (cached) yes
checking whether the gcc -std=gnu99 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for ANSI C header files... (cached) yes
checking whether time.h and sys/time.h may both be included... yes
checking for unistd.h... (cached) yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking for stdint.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for C thread-local keyword... __thread
checking size of unsigned int... 4
checking size of unsigned long... 8
checking for uint32_t... yes
checking for sin in -lm... yes
checking for BSDgettimeofday... no
checking for gettimeofday... yes
checking for time... yes
checking for qsort_r... yes
checking for getpid... yes
checking for gettid syscall... yes
checking for isnan... yes
checking for isinf... yes
checking for copysign... yes
checking for mkoctfile... no
checking for mex... mex
checking for working HUGE_VAL... ok
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating nlopt.pc
config.status: creating api/Makefile
config.status: creating util/Makefile
config.status: creating octave/Makefile
config.status: creating direct/Makefile
config.status: creating cdirect/Makefile
config.status: creating stogo/Makefile
config.status: creating praxis/Makefile
config.status: creating luksan/Makefile
config.status: creating crs/Makefile
config.status: creating mlsl/Makefile
config.status: creating mma/Makefile
config.status: creating cobyla/Makefile
config.status: creating newuoa/Makefile
config.status: creating neldermead/Makefile
config.status: creating auglag/Makefile
config.status: creating bobyqa/Makefile
config.status: creating isres/Makefile
config.status: creating slsqp/Makefile
config.status: creating esch/Makefile
config.status: creating test/Makefile
config.status: creating swig/Makefile
config.status: creating swig/nlopt.scm
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
make  all-recursive
make[1]: Entering directory '/tmp/RtmpyUZU19/R.INSTALL604c1767fe44/nloptr/src/nlopt_src'
Making all in util
make[2]: Entering directory '/tmp/RtmpyUZU19/R.INSTALL604c1767fe44/nloptr/src/nlopt_src/util'
/bin/bash ../libtool  --tag=CC   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -I../api   -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT mt19937ar.lo -MD -MP -MF .deps/mt19937ar.Tpo -c -o mt19937ar.lo mt19937ar.c
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT mt19937ar.lo -MD -MP -MF .deps/mt19937ar.Tpo -c mt19937ar.c  -fPIC -DPIC -o .libs/mt19937ar.o
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT mt19937ar.lo -MD -MP -MF .deps/mt19937ar.Tpo -c mt19937ar.c -o mt19937ar.o >/dev/null 2>&1
mv -f .deps/mt19937ar.Tpo .deps/mt19937ar.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -I../api   -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT sobolseq.lo -MD -MP -MF .deps/sobolseq.Tpo -c -o sobolseq.lo sobolseq.c
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT sobolseq.lo -MD -MP -MF .deps/sobolseq.Tpo -c sobolseq.c  -fPIC -DPIC -o .libs/sobolseq.o
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT sobolseq.lo -MD -MP -MF .deps/sobolseq.Tpo -c sobolseq.c -o sobolseq.o >/dev/null 2>&1
mv -f .deps/sobolseq.Tpo .deps/sobolseq.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -I../api   -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT timer.lo -MD -MP -MF .deps/timer.Tpo -c -o timer.lo timer.c
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT timer.lo -MD -MP -MF .deps/timer.Tpo -c timer.c  -fPIC -DPIC -o .libs/timer.o
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT timer.lo -MD -MP -MF .deps/timer.Tpo -c timer.c -o timer.o >/dev/null 2>&1
mv -f .deps/timer.Tpo .deps/timer.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -I../api   -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT stop.lo -MD -MP -MF .deps/stop.Tpo -c -o stop.lo stop.c
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT stop.lo -MD -MP -MF .deps/stop.Tpo -c stop.c  -fPIC -DPIC -o .libs/stop.o
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT stop.lo -MD -MP -MF .deps/stop.Tpo -c stop.c -o stop.o >/dev/null 2>&1
mv -f .deps/stop.Tpo .deps/stop.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -I../api   -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT redblack.lo -MD -MP -MF .deps/redblack.Tpo -c -o redblack.lo redblack.c
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT redblack.lo -MD -MP -MF .deps/redblack.Tpo -c redblack.c  -fPIC -DPIC -o .libs/redblack.o
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT redblack.lo -MD -MP -MF .deps/redblack.Tpo -c redblack.c -o redblack.o >/dev/null 2>&1
mv -f .deps/redblack.Tpo .deps/redblack.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -I../api   -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT qsort_r.lo -MD -MP -MF .deps/qsort_r.Tpo -c -o qsort_r.lo qsort_r.c
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT qsort_r.lo -MD -MP -MF .deps/qsort_r.Tpo -c qsort_r.c  -fPIC -DPIC -o .libs/qsort_r.o
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT qsort_r.lo -MD -MP -MF .deps/qsort_r.Tpo -c qsort_r.c -o qsort_r.o >/dev/null 2>&1
mv -f .deps/qsort_r.Tpo .deps/qsort_r.Plo
/bin/bash ../libtool  --tag=CC   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -I../api   -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT rescale.lo -MD -MP -MF .deps/rescale.Tpo -c -o rescale.lo rescale.c
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT rescale.lo -MD -MP -MF .deps/rescale.Tpo -c rescale.c  -fPIC -DPIC -o .libs/rescale.o
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I../api -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -MT rescale.lo -MD -MP -MF .deps/rescale.Tpo -c rescale.c -o rescale.o >/dev/null 2>&1
mv -f .deps/rescale.Tpo .deps/rescale.Plo
/bin/bash ../libtool  --tag=CC   --mode=link g++  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g   -o libutil.la  mt19937ar.lo sobolseq.lo timer.lo stop.lo redblack.lo qsort_r.lo rescale.lo  -lm 
libtool: link: ERROR: no information for variable 'AR' cru .libs/libutil.a .libs/mt19937ar.o .libs/sobolseq.o .libs/timer.o .libs/stop.o .libs/redblack.o .libs/qsort_r.o .libs/rescale.o 
../libtool: line 1102: ERROR:: command not found
Makefile:371: recipe for target 'libutil.la' failed
make[2]: Leaving directory '/tmp/RtmpyUZU19/R.INSTALL604c1767fe44/nloptr/src/nlopt_src/util'
make[2]: *** [libutil.la] Error 127
Makefile:574: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/tmp/RtmpyUZU19/R.INSTALL604c1767fe44/nloptr/src/nlopt_src'
Makefile:438: recipe for target 'all' failed
make: *** [all] Error 2
ERROR: configuration failed for package ‘nloptr’
* removing ‘/home/thomas/R/x86_64-pc-linux-gnu-library/3.4/nloptr’
Warning in install.packages :
  installation of package ‘nloptr’ had non-zero exit status
ERROR: dependency ‘nloptr’ is not available for package ‘lme4’
* removing ‘/home/thomas/R/x86_64-pc-linux-gnu-library/3.4/lme4’
Warning in install.packages :
  installation of package ‘lme4’ had non-zero exit status

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

I tried to look up using the part "installation of package had non-zero exit status" but I could not find anything that worked. If anyone had a similar issue and has found a solution, I would love to hear about it.

Cheers!

This is a toolchain problem. Error 137 indicates that the command or library needed for one step in the makefile cannot be found or does not exist. That may be due to an installation that did not include

sudo apt-get install build-essential

It is also possible that once that problem is fixed another failure will arise because of the version of R, which is badly out-of-date.

Hi,
I just found the answer there: https://stackoverflow.com/questions/62900525/install-lme4-from-cran-on-ubuntu
The dependency nloptr available on CRAN is only working for R>=4 so you need to manually install a old version of nloptr

1 Like

Was the next to last line

build-essential is already the newest version (12.8ubuntu1).

Thanks for the answer!
I tried that but I got this:

0 upgraded, 0 newly installed, 0 to remove 

Meaning it was already included, so nothing changed in Rstudio...