Installing RStan on Mojave Mac OS X. Issue with C++ toolchain

Hi. I’m having an issue using RStan version 2.19.2 on my Mac (OS 10.14.5). It seems that RStan is not able to find the proper build toolchain, even though I followed the instructions here to install the toolchain and point R to it.

Thanks in advance for any help!

Other possibly relevant information:

  • using R 3.6.1
  • RStudio 1.2.5019
  • 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")
    Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    setting value
    version R version 3.6.1 (2019-07-05)
    os macOS Mojave 10.14.5
    system x86_64, darwin15.6.0
    ui RStudio
    language (EN)
    collate en_US.UTF-8
    ctype en_US.UTF-8
    tz America/Indiana/Indianapolis
    date 2019-11-14

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.0)
BH 1.69.0-1 2019-01-07 [1] CRAN (R 3.6.0)
callr 3.3.2 2019-09-22 [1] CRAN (R 3.6.0)
checkmate 1.9.4 2019-07-04 [1] CRAN (R 3.6.0)
cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.0)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.0)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)
desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.0)
digest 0.6.22 2019-10-21 [1] CRAN (R 3.6.0)
ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.0)
fansi 0.4.0 2018-10-05 [1] CRAN (R 3.6.0)
ggplot2 * 3.2.1 2019-08-10 [1] CRAN (R 3.6.0)
glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0)
gridExtra 2.3 2017-09-09 [1] CRAN (R 3.6.0)
gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.0)
inline 0.3.15 2018-05-18 [1] CRAN (R 3.6.0)
labeling 0.3 2014-08-23 [1] CRAN (R 3.6.0)
lattice 0.20-38 2018-11-04 [1] CRAN (R 3.6.1)
lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.6.0)
loo 2.1.0 2019-03-13 [1] CRAN (R 3.6.0)
magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)
MASS 7.3-51.4 2019-03-31 [1] CRAN (R 3.6.1)
Matrix 1.2-17 2019-03-22 [1] CRAN (R 3.6.1)
matrixStats 0.55.0 2019-09-07 [1] CRAN (R 3.6.0)
mgcv 1.8-28 2019-03-21 [1] CRAN (R 3.6.1)
munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.0)
nlme 3.1-140 2019-05-12 [1] CRAN (R 3.6.1)
pillar 1.4.2 2019-06-29 [1] CRAN (R 3.6.0)
pkgbuild 1.0.6 2019-10-09 [1] CRAN (R 3.6.0)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.0)
plyr 1.8.4 2016-06-08 [1] CRAN (R 3.6.0)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.0)
processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.0)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.0)
R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.1)
RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 3.6.0)
Rcpp * 1.0.3 2019-11-08 [1] CRAN (R 3.6.0)
RcppEigen 0.3.3.5.0 2018-11-24 [1] CRAN (R 3.6.0)
reshape2 1.4.3 2017-12-11 [1] CRAN (R 3.6.0)
rlang 0.4.1 2019-10-24 [1] CRAN (R 3.6.0)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.0)
rstan * 2.19.2 2019-07-09 [1] CRAN (R 3.6.0)
scales 1.0.0 2018-08-09 [1] CRAN (R 3.6.0)
StanHeaders * 2.19.0 2019-09-07 [1] CRAN (R 3.6.0)
stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0)
stringr * 1.4.0 2019-02-10 [1] CRAN (R 3.6.0)
tibble * 2.1.3 2019-06-06 [1] CRAN (R 3.6.0)
utf8 1.1.4 2018-05-24 [1] CRAN (R 3.6.0)
vctrs 0.2.0 2019-07-05 [1] CRAN (R 3.6.0)
viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.6.0)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0)
zeallot 0.1.0 2018-01-28 [1] CRAN (R 3.6.0)

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

What is the error message?

Ultimately I want to use brm() function in β€œbrms” (which, as I understand, delegates to RStan). When I call brm() I get the following error message:

Compiling the C++ model
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! dyld: Library not loaded: @rpath/DVTFoundation.framework/Versions/A/DVTFoundation
Referenced from: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
Reason: no suitable image found. Did find:
/Applications/Xcode.app/Contents/Developer/usr/bin/…/…/…/SharedFrameworks/DVTFoundation.framework/Versions/A/DVTFoundation: cannot load β€˜/Applications/Xcode.app/Contents/Developer/usr/bin/…/…/…/SharedFrameworks/DVTFoundation.framework/Versions/A/DVTFoundation’ because Objective-C garbage collection is not supported
xcrun: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!
xcrun: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch
In addition: Warning messages:
1: In system2(file.path(R.home(component = β€œbin”), β€œR”), args = paste(β€œCMD config”, :
running command β€˜β€™/Library/Frameworks/R.framework/Resources/bin/R’ CMD config CXX14 2>/dev/null’ had status 69
2: In .fun(model_code = .x1) :
C++ compiler not found on system. If absent, see
https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started
3: In system(cmd, intern = !verbose) :

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! dyld: Library not loaded: @rpath/DVTFoundation.framework/Versions/A/DVTFoundation
Referenced from: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild
Reason: no suitable image found. Did find:
/Applications/Xcode.app/Contents/Developer/usr/bin/…/…/…/SharedFrameworks/DVTFoundation.framework/Versions/A/DVTFoundation: cannot load β€˜/Applications/Xcode.app/Contents/Developer/usr/bin/…/…/…/SharedFrameworks/DVTFoundation.framework/Versions/A/DVTFoundation’ because Objective-C garbage collection is not supported
xcrun: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!
xcrun: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch

Try first doing xcode-select --install in the Terminal app or the Terminal tab of RStudio.

I ended up installing XCode via the AppStore and it works now.

Would have done this earlier, but my impression is that this should have been accomplished by following the instructions on the RStan-Getting-Started page, which apparently didn’t work for me.

Thank you for your assistance.

1 Like

@mattsetz Sorry for the hassle but glad it’s working now!