Unable to install any packages in R - how to fix that?

For my bachelor thesis I need to work with "car" and "mlogit" and need to install these packages in RStudio. For whatever reason installing them does not work.
For
install.packages("car")
or any other package, I get error messages saying, that installation of package xyz "had non-zero exit status".

I tried reinstalling R and RStudio, made sure it's the latest version and checked for compatibility (I'm using Ubuntu 20.04 LTS) but I just can't get it to work. Other posts here and elsewhere could not help me resolve the issue. I'm connected to the internet, and deactivated "use secure download method for http" in global options. Also trying to install via R and not RStudio did not work.

I'm sorry if this post is not formatted properly, I've only used R on very basic levels before and am a little overwhelmed with the amount of information and possibilities. Help would be very much appreciated!

1 Like

Can you post the complete error message you get? We need more information to be able to help you.

This is part 2:

checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether the C++ compiler works... no
configure: error: in `/tmp/Rtmp1UE3Tm/R.INSTALL28df5f0245e9/nloptr':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘nloptr’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/nloptr’
Warning in install.packages :
  installation of package ‘nloptr’ had non-zero exit status
* installing *source* package ‘statmod’ ...
** Paket ‘statmod’ erfolgreich entpackt und MD5 Summen überprüft
** using staged installation
** libs
sh: 1: make: not found
Warnung in system(cmd) Fehler bei der Ausführung des Befehls
ERROR: compilation failed for package ‘statmod’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/statmod’
Warning in install.packages :
  installation of package ‘statmod’ had non-zero exit status
* installing *source* package ‘RcppEigen’ ...
** Paket ‘RcppEigen’ erfolgreich entpackt und MD5 Summen überprüft
** using staged installation
** libs
sh: 1: make: not found
Warnung in system(cmd) Fehler bei der Ausführung des Befehls
ERROR: compilation failed for package ‘RcppEigen’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/RcppEigen’
Warning in install.packages :
  installation of package ‘RcppEigen’ had non-zero exit status
* installing *source* package ‘purrr’ ...
** Paket ‘purrr’ erfolgreich entpackt und MD5 Summen überprüft
** using staged installation
** libs
sh: 1: make: not found
Warnung in system(cmd) Fehler bei der Ausführung des Befehls
ERROR: compilation failed for package ‘purrr’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/purrr’
Warning in install.packages :
  installation of package ‘purrr’ had non-zero exit status
ERROR: dependency ‘stringi’ is not available for package ‘stringr’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/stringr’
Warning in install.packages :
  installation of package ‘stringr’ had non-zero exit status
* installing *source* package ‘lifecycle’ ...
** Paket ‘lifecycle’ erfolgreich entpackt und MD5 Summen überprüft
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Fehler in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  namespace ‘rlang’ 0.4.6 is being loaded, but >= 0.4.10 is required
Ruft auf: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Ausführung angehalten
ERROR: lazy loading failed for package ‘lifecycle’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/lifecycle’
* restoring previous ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/lifecycle’
Warning in install.packages :
  installation of package ‘lifecycle’ had non-zero exit status
* installing *source* package ‘vctrs’ ...
** Paket ‘vctrs’ erfolgreich entpackt und MD5 Summen überprüft
** using staged installation
** libs
sh: 1: make: not found
Warnung in system(cmd) Fehler bei der Ausführung des Befehls
ERROR: compilation failed for package ‘vctrs’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/vctrs’
* restoring previous ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/vctrs’
Warning in install.packages :
  installation of package ‘vctrs’ had non-zero exit status
ERROR: dependency ‘xfun’ is not available for package ‘highr’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/highr’
Warning in install.packages :
  installation of package ‘highr’ had non-zero exit status
ERROR: dependencies ‘xfun’, ‘mime’ are not available for package ‘markdown’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/markdown’
Warning in install.packages :
  installation of package ‘markdown’ had non-zero exit status
ERROR: dependencies ‘matrixStats’, ‘RcppArmadillo’ are not available for package ‘conquer’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/conquer’
Warning in install.packages :
  installation of package ‘conquer’ had non-zero exit status
ERROR: dependencies ‘zip’, ‘stringi’ are not available for package ‘openxlsx’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/openxlsx’
Warning in install.packages :
  installation of package ‘openxlsx’ had non-zero exit status
ERROR: dependency ‘sp’ is not available for package ‘maptools’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/maptools’
Warning in install.packages :
  installation of package ‘maptools’ had non-zero exit status
ERROR: dependencies ‘minqa’, ‘nloptr’, ‘statmod’, ‘RcppEigen’ are not available for package ‘lme4’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/lme4’
Warning in install.packages :
  installation of package ‘lme4’ had non-zero exit status
ERROR: dependency ‘purrr’ is not available for package ‘tidyselect’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/tidyselect’
Warning in install.packages :
  installation of package ‘tidyselect’ had non-zero exit status
* installing *source* package ‘readr’ ...
** Paket ‘readr’ erfolgreich entpackt und MD5 Summen überprüft
** using staged installation
** libs
sh: 1: make: not found
Warnung in system(cmd) Fehler bei der Ausführung des Befehls
ERROR: compilation failed for package ‘readr’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/readr’
Warning in install.packages :
  installation of package ‘readr’ had non-zero exit status
ERROR: dependencies ‘highr’, ‘markdown’, ‘stringr’, ‘yaml’, ‘xfun’ are not available for package ‘knitr’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/knitr’
Warning in install.packages :
  installation of package ‘knitr’ had non-zero exit status
ERROR: dependencies ‘SparseM’, ‘conquer’ are not available for package ‘quantreg’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/quantreg’
Warning in install.packages :
  installation of package ‘quantreg’ had non-zero exit status
ERROR: dependency ‘tidyselect’ is not available for package ‘dplyr’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/dplyr’
Warning in install.packages :
  installation of package ‘dplyr’ had non-zero exit status
ERROR: dependencies ‘readr’, ‘tidyselect’ are not available for package ‘haven’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/haven’
Warning in install.packages :
  installation of package ‘haven’ had non-zero exit status
ERROR: dependencies ‘dplyr’, ‘purrr’, ‘tidyselect’ are not available for package ‘tidyr’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/tidyr’
Warning in install.packages :
  installation of package ‘tidyr’ had non-zero exit status
ERROR: dependencies ‘haven’, ‘curl’, ‘data.table’, ‘readxl’, ‘openxlsx’ are not available for package ‘rio’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/rio’
Warning in install.packages :
  installation of package ‘rio’ had non-zero exit status
ERROR: dependencies ‘dplyr’, ‘purrr’, ‘stringr’, ‘tidyr’ are not available for package ‘broom’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/broom’
Warning in install.packages :
  installation of package ‘broom’ had non-zero exit status
ERROR: dependencies ‘lme4’, ‘broom’, ‘dplyr’, ‘knitr’ are not available for package ‘pbkrtest’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/pbkrtest’
Warning in install.packages :
  installation of package ‘pbkrtest’ had non-zero exit status
ERROR: dependencies ‘pbkrtest’, ‘quantreg’, ‘maptools’, ‘rio’, ‘lme4’ are not available for package ‘car’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/car’
Warning in install.packages :
  installation of package ‘car’ had non-zero exit status

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

This is what I get. I have to post it in two parts, since it's too long. Part 1:

Installing package into ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
also installing the dependencies ‘mime’, ‘purrr’, ‘stringr’, ‘tidyr’, ‘lifecycle’, ‘rlang’, ‘tidyselect’, ‘vctrs’, ‘highr’, ‘markdown’, ‘yaml’, ‘xfun’, ‘matrixStats’, ‘RcppArmadillo’, ‘readr’, ‘zip’, ‘stringi’, ‘broom’, ‘dplyr’, ‘knitr’, ‘SparseM’, ‘conquer’, ‘sp’, ‘haven’, ‘curl’, ‘data.table’, ‘readxl’, ‘openxlsx’, ‘minqa’, ‘nloptr’, ‘statmod’, ‘RcppEigen’, ‘pbkrtest’, ‘quantreg’, ‘maptools’, ‘rio’, ‘lme4’

versuche URL 'https://cloud.r-project.org/src/contrib/mime_0.10.tar.gz'
Content type 'application/x-gzip' length 13047 bytes (12 KB)
==================================================
downloaded 12 KB

versuche URL 'https://cloud.r-project.org/src/contrib/purrr_0.3.4.tar.gz'
Content type 'application/x-gzip' length 375062 bytes (366 KB)
==================================================
downloaded 366 KB

versuche URL 'https://cloud.r-project.org/src/contrib/stringr_1.4.0.tar.gz'
Content type 'application/x-gzip' length 135777 bytes (132 KB)
==================================================
downloaded 132 KB

versuche URL 'https://cloud.r-project.org/src/contrib/tidyr_1.1.3.tar.gz'
Content type 'application/x-gzip' length 707909 bytes (691 KB)
==================================================
downloaded 691 KB

versuche URL 'https://cloud.r-project.org/src/contrib/lifecycle_1.0.0.tar.gz'
Content type 'application/x-gzip' length 83389 bytes (81 KB)
==================================================
downloaded 81 KB

versuche URL 'https://cloud.r-project.org/src/contrib/rlang_0.4.11.tar.gz'
Content type 'application/x-gzip' length 861727 bytes (841 KB)
==================================================
downloaded 841 KB

versuche URL 'https://cloud.r-project.org/src/contrib/tidyselect_1.1.1.tar.gz'
Content type 'application/x-gzip' length 92088 bytes (89 KB)
==================================================
downloaded 89 KB

versuche URL 'https://cloud.r-project.org/src/contrib/vctrs_0.3.8.tar.gz'
Content type 'application/x-gzip' length 782608 bytes (764 KB)
==================================================
downloaded 764 KB

versuche URL 'https://cloud.r-project.org/src/contrib/highr_0.9.tar.gz'
Content type 'application/x-gzip' length 15188 bytes (14 KB)
==================================================
downloaded 14 KB

versuche URL 'https://cloud.r-project.org/src/contrib/markdown_1.1.tar.gz'
Content type 'application/x-gzip' length 81050 bytes (79 KB)
==================================================
downloaded 79 KB

versuche URL 'https://cloud.r-project.org/src/contrib/yaml_2.2.1.tar.gz'
Content type 'application/x-gzip' length 92670 bytes (90 KB)
==================================================
downloaded 90 KB

versuche URL 'https://cloud.r-project.org/src/contrib/xfun_0.22.tar.gz'
Content type 'application/x-gzip' length 105388 bytes (102 KB)
==================================================
downloaded 102 KB

versuche URL 'https://cloud.r-project.org/src/contrib/matrixStats_0.58.0.tar.gz'
Content type 'application/x-gzip' length 195698 bytes (191 KB)
==================================================
downloaded 191 KB

versuche URL 'https://cloud.r-project.org/src/contrib/RcppArmadillo_0.10.4.0.0.tar.gz'
Content type 'application/x-gzip' length 1667929 bytes (1.6 MB)
==================================================
downloaded 1.6 MB

versuche URL 'https://cloud.r-project.org/src/contrib/readr_1.4.0.tar.gz'
Content type 'application/x-gzip' length 488946 bytes (477 KB)
==================================================
downloaded 477 KB

versuche URL 'https://cloud.r-project.org/src/contrib/zip_2.1.1.tar.gz'
Content type 'application/x-gzip' length 112865 bytes (110 KB)
==================================================
downloaded 110 KB

versuche URL 'https://cloud.r-project.org/src/contrib/stringi_1.5.3.tar.gz'
Content type 'application/x-gzip' length 7293930 bytes (7.0 MB)
==================================================
downloaded 7.0 MB

versuche URL 'https://cloud.r-project.org/src/contrib/broom_0.7.6.tar.gz'
Content type 'application/x-gzip' length 631820 bytes (617 KB)
==================================================
downloaded 617 KB

versuche URL 'https://cloud.r-project.org/src/contrib/dplyr_1.0.5.tar.gz'
Content type 'application/x-gzip' length 949019 bytes (926 KB)
==================================================
downloaded 926 KB

versuche URL 'https://cloud.r-project.org/src/contrib/knitr_1.33.tar.gz'
Content type 'application/x-gzip' length 892378 bytes (871 KB)
==================================================
downloaded 871 KB

versuche URL 'https://cloud.r-project.org/src/contrib/SparseM_1.81.tar.gz'
Content type 'application/x-gzip' length 735100 bytes (717 KB)
==================================================
downloaded 717 KB

versuche URL 'https://cloud.r-project.org/src/contrib/conquer_1.0.2.tar.gz'
Content type 'application/x-gzip' length 12322 bytes (12 KB)
==================================================
downloaded 12 KB

versuche URL 'https://cloud.r-project.org/src/contrib/sp_1.4-5.tar.gz'
Content type 'application/x-gzip' length 1049195 bytes (1.0 MB)
==================================================
downloaded 1.0 MB

versuche URL 'https://cloud.r-project.org/src/contrib/haven_2.4.1.tar.gz'
Content type 'application/x-gzip' length 282833 bytes (276 KB)
==================================================
downloaded 276 KB

versuche URL 'https://cloud.r-project.org/src/contrib/curl_4.3.1.tar.gz'
Content type 'application/x-gzip' length 793230 bytes (774 KB)
==================================================
downloaded 774 KB

versuche URL 'https://cloud.r-project.org/src/contrib/data.table_1.14.0.tar.gz'
Content type 'application/x-gzip' length 5303849 bytes (5.1 MB)
==================================================
downloaded 5.1 MB

versuche URL 'https://cloud.r-project.org/src/contrib/readxl_1.3.1.tar.gz'
Content type 'application/x-gzip' length 2056165 bytes (2.0 MB)
==================================================
downloaded 2.0 MB

versuche URL 'https://cloud.r-project.org/src/contrib/openxlsx_4.2.3.tar.gz'
Content type 'application/x-gzip' length 1275121 bytes (1.2 MB)
==================================================
downloaded 1.2 MB

versuche URL 'https://cloud.r-project.org/src/contrib/minqa_1.2.4.tar.gz'
Content type 'application/x-gzip' length 53548 bytes (52 KB)
==================================================
downloaded 52 KB

versuche 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

versuche URL 'https://cloud.r-project.org/src/contrib/statmod_1.4.35.tar.gz'
Content type 'application/x-gzip' length 61864 bytes (60 KB)
==================================================
downloaded 60 KB

versuche URL 'https://cloud.r-project.org/src/contrib/RcppEigen_0.3.3.9.1.tar.gz'
Content type 'application/x-gzip' length 1633360 bytes (1.6 MB)
==================================================
downloaded 1.6 MB

versuche URL 'https://cloud.r-project.org/src/contrib/pbkrtest_0.5.1.tar.gz'
Content type 'application/x-gzip' length 246327 bytes (240 KB)
==================================================
downloaded 240 KB

versuche URL 'https://cloud.r-project.org/src/contrib/quantreg_5.85.tar.gz'
Content type 'application/x-gzip' length 1015594 bytes (991 KB)
==================================================
downloaded 991 KB

versuche URL 'https://cloud.r-project.org/src/contrib/maptools_1.1-1.tar.gz'
Content type 'application/x-gzip' length 1586925 bytes (1.5 MB)
==================================================
downloaded 1.5 MB

versuche URL 'https://cloud.r-project.org/src/contrib/rio_0.5.26.tar.gz'
Content type 'application/x-gzip' length 384305 bytes (375 KB)
==================================================
downloaded 375 KB

versuche URL 'https://cloud.r-project.org/src/contrib/lme4_1.1-26.tar.gz'
Content type 'application/x-gzip' length 3297635 bytes (3.1 MB)
==================================================
downloaded 3.1 MB

versuche URL 'https://cloud.r-project.org/src/contrib/car_3.0-10.tar.gz'
Content type 'application/x-gzip' length 501293 bytes (489 KB)
==================================================
downloaded 489 KB

* installing *source* package ‘mime’ ...
** Paket ‘mime’ erfolgreich entpackt und MD5 Summen überprüft
** using staged installation
** libs
sh: 1: make: not found
Warnung in system(cmd) Fehler bei der Ausführung des Befehls
ERROR: compilation failed for package ‘mime’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/mime’
Warning in install.packages :
  installation of package ‘mime’ had non-zero exit status
* installing *source* package ‘rlang’ ...
** Paket ‘rlang’ erfolgreich entpackt und MD5 Summen überprüft
** using staged installation
** libs
sh: 1: make: not found
Warnung in system(cmd) Fehler bei der Ausführung des Befehls
ERROR: compilation failed for package ‘rlang’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/rlang’
* restoring previous ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/rlang’
Warning in install.packages :
  installation of package ‘rlang’ had non-zero exit status
* installing *source* package ‘yaml’ ...
** Paket ‘yaml’ erfolgreich entpackt und MD5 Summen überprüft
** using staged installation
** libs
sh: 1: make: not found
Warnung in system(cmd) Fehler bei der Ausführung des Befehls
ERROR: compilation failed for package ‘yaml’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/yaml’
Warning in install.packages :
  installation of package ‘yaml’ had non-zero exit status
* installing *source* package ‘xfun’ ...
** Paket ‘xfun’ erfolgreich entpackt und MD5 Summen überprüft
** using staged installation
** libs
sh: 1: make: not found
Warnung in system(cmd) Fehler bei der Ausführung des Befehls
ERROR: compilation failed for package ‘xfun’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/xfun’
Warning in install.packages :
  installation of package ‘xfun’ had non-zero exit status
* installing *source* package ‘matrixStats’ ...
** Paket ‘matrixStats’ erfolgreich entpackt und MD5 Summen überprüft
** using staged installation
** libs
sh: 1: make: not found
Warnung in system(cmd) Fehler bei der Ausführung des Befehls
ERROR: compilation failed for package ‘matrixStats’
* removing ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6/matrixStats’
Warning in install.packages :
  installation of package ‘matrixStats’ had non-zero exit status
* installing *source* package ‘RcppArmadillo’ ...
** Paket ‘RcppArmadillo’ erfolgreich entpackt und MD5 Summen überprüft
** using staged installation
/usr/lib/R/bin/config: 1: eval: make: not found
/usr/lib/R/bin/config: 1: eval: make: not found
/usr/lib/R/bin/config: 1: eval: make: not found
/usr/lib/R/bin/config: 1: eval: make: not found
/usr/lib/R/bin/config: 1: eval: make: not found
/usr/lib/R/bin/config: 1: eval: make: not found
/usr/lib/R/bin/config: 1: eval: make: not found
/usr/lib/R/bin/config: 1: eval: make: not found
/usr/lib/R/bin/config: 1: eval: make: not found
/usr/lib/R/bin/config: 1: eval: make: not found
/usr/lib/R/bin/config: 1: eval: make: not found
/usr/lib/R/bin/config: 1: eval: make: not found

`

Since you are on a Linux OS and you are using a regular CRAN mirror you are forced to compile packages from source but to be able to do that, you need to have the proper tools installed in your system, I don't have a list of every possible system dependency but these are some common ones you might try:

  • cmake
  • make
  • gcc
  • g++
  • gfortran

I will try this, thanks. How do I install dependencies?
I tried via install.packages() and RStudio told me:

> install.packages("cmake")
Installing package into ‘/home/clara/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘cmake’ is not available (for R version 3.6.3)

Is this just because I used the wrong function?

Those are system dependencies, not R packages, you have to install them from a system terminal not from the R console, I don't know what Linux distribution you are using but for example on Debian based systems the command would be

sudo apt install cmake

EDIT: I just realized you said you are using Ubuntu (which is a Debian-based Linux distribution) so using sudo apt insall should work just fine.

Ubuntu is aa Debian version. The

sudo apt install cmake

is standard.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.