Can't download package for RStudio

Hi guys,

First time to learn RStudio, I am running Version 1.2.5033 at Mac ios, having trouble to install a package. I tried to reinstall R but still have the same issue "installation of package ‘Rcpp’ had non-zero exit status". I have no idea how to fix it since I am beginner. Any suggestions would be a huge help, many thanks!

> install.packages("dplyr")
also installing the dependency ‘Rcpp’

  There is a binary version available but the source version is later:
     binary  source needs_compilation
Rcpp  1.0.4              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) yes
trying URL ''
Content type 'application/x-gzip' length 6859111 bytes (6.5 MB)
downloaded 6.5 MB

The downloaded binary packages are in
installing the source package ‘Rcpp’

trying URL ''
Content type 'application/x-gzip' length 2751467 bytes (2.6 MB)
downloaded 2.6 MB

* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp’
Warning in install.packages :
  installation of package ‘Rcpp’ had non-zero exit status

The downloaded source packages are in

Since the most recent version of Rcpp didn't have binaries on CRAN at the time you were trying to install it, you needed Xcode Command Line Tools in order to compile it from source (the error message mentioning xcrun is the telltale sign there).

The TL;DR solution is to run:
xcode-select --install
from the command line/terminal, but if you want more info, see section 9.2 at the link below:

1 Like

Thanks so much Mara! I tried your code and it works like a magic!

1 Like

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

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