I don’t seem to be able to successfully install the C++ toolchain. I used the recommendation at and downloaded the toolchain installer macos-rtools-3.0.0.pkg from

The installation appears to be successful, but rstan still won’t install and if I enter
pkgbuild::has_build_tools(debug = TRUE),
I still get “False” and a pop-up link that tells me “Install Build Tools” and tries to send me to CNET to obtain them.

Thanks for your help!


  • Operating System High Sierra 10.13.6

  • RStan Version: Attempting to install 2.19.2

  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars"))) # clang: start
    CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
    CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
    CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

clang: end

  • Output of devtools::session_info("rstan")

R version 3.5.1 (2018-07-02) – “Feather Spray”
Copyright © 2018 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type ‘license()’ or ‘licence()’ for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type ‘contributors()’ for more information and
‘citation()’ on how to cite R or R packages in publications.

Type ‘demo()’ for some demos, ‘help()’ for on-line help, or
‘help.start()’ for an HTML browser interface to help.
Type ‘q()’ to quit R.

Sys.setenv(MAKEFLAGS = “-j4”) # four cores used
install.packages(“rstan”, type = “source”)
trying URL ‘
Content type ‘application/x-gzip’ length 909934 bytes (888 KB)
downloaded 888 KB

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

The downloaded source packages are in

No documentation for ‘rstan’ in specified packages and libraries:
you could try ‘??rstan’
writeLines(readLines(file.path(Sys.getenv(“HOME”), “.R/Makevars”)))

clang: start

CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

clang: end

─ Session info ────────────────────────────────────────────────────────────────────────────────
setting value
version R version 3.5.1 (2018-07-02)
os macOS High Sierra 10.13.6
system x86_64, darwin15.6.0
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/New_York
date 2019-11-03

─ Packages ────────────────────────────────────────────────────────────────────────────────────
! package * version date lib source
R rstan [?]

[1] /Library/Frameworks/R.framework/Versions/3.5/Resources/library

R ── Package was removed from disk.

Try doing in the Terminal app or the Terminal window of RStudio

xcode-select --install

This worked. Thanks!