RStan

I don’t seem to be able to successfully install the C++ toolchain. I used the recommendation at RStan Getting Started · stan-dev/rstan Wiki · GitHub and downloaded the toolchain installer macos-rtools-3.0.0.pkg from GitHub - coatless-mac/r-macos-rtools: Scripts to build an **unofficial** Rtools-esq installer for the macOS R toolchain

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!

Info:

  • 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 (C) 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 ‘https://cran.rstudio.com/src/contrib/rstan_2.19.2.tar.gz
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
‘/private/var/folders/35/cn5fsfgj3z35m5fbt35zhdt00000gn/T/Rtmp46yKTJ/downloaded_packages’

help(“rstan”)
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

devtools::session_info(“rstan”)
─ 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!