简体   繁体   中英

Can't install R packages on Linux Mint 17

Running R 3.1.2 on Linux Mint 17, I get a non-zero exit status when I try to install popular packages. The full output of an example install.packages attempt is as follows:

> install.packages("plyr")
Installing package into ‘/home/joe_kendrick/R/x86_64-pc-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/plyr_1.8.1.tar.gz'
Content type 'application/x-gzip' length 393233 bytes (384 Kb)
opened URL
==================================================
downloaded 384 Kb

* installing *source* package ‘plyr’ ...
** package ‘plyr’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/share/R/include -DNDEBUG   -I"/usr/lib/R/site-library/Rcpp/include"   -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
/bin/bash: g++: command not found
make: *** [RcppExports.o] Error 127
ERROR: compilation failed for package ‘plyr’
* removing ‘/home/joe_kendrick/R/x86_64-pc-linux-gnu-library/3.1/plyr’

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

I get essentially the same message for other packages I attempt to install, eg ggplot2 and vegan , though in many cases it is more verbose as it tries and fails to install dependencies.

This seems like a somewhat common issue, but others seem to have either outdated software or insufficient memory . I am running the latest stable release of both Mint and R, and I have plenty of RAM and a swap file, so I don't think either of these are causing my issue.

Per the error message

 /bin/bash: g++: command not found

you need to install a C++ compiler. I would start with one of these:

 sudo apt-get install build-essentials        # key tools

or

 sudo apt-get install r-base-dev              # many development tools for R

or of course

 sudo apt-get install r-cran-rcpp             # to not install from source

though the Rcpp you get may be older than the one you need.

There is a list r-sig-debian for users of Debian-based systems.

In my case, I am running a fairly new installation of Mint 18, and I was missing certain packages. Per the error message in R, I attempted to install "readr", but that wouldn't install because I was missing an underlying package, "libcurl4-openssl-dev". I apt-got that, then readr install without error, and now my packages for RStudio load as expected.

You should test which repository here 1 works for your Linux Distro. Try add one by one to your '/etc/apt/sources.list' and run:
sudo apt update
sudo apt install r-base
On Linux Mint 18.3 it worked with:
deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/
or
deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran40/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM