Trouble with initial use of rstan

Operating System: macOS Catalina, Version 10.15.1 (19B88)
Interface Version: rstan_2.19.2 (found via ‘sessionInfo()’)
Compiler/Toolkit: Using R Version “x86_64-apple-darwin15.6.0” (3.6.1)

After following the instructions in the RStan Getting Started guide, I get the following error message

Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! /bin/sh: /usr/local/clang7/bin/clang++: No such file or directory
make: *** [fileba113a08d682.o] Error 127
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB fileba113a08d682.cpp 2> fileba113a08d682.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection

after running

schools_dat <- list(J = 8, y = c(28, 8, -3, 7, -1, 1, 18, 12), sigma = c(15, 10, 16, 11, 9, 11, 10, 18))
fit <- stan(file = ‘8schools.stan’, data = schools_dat)

where ‘8schools.stan’ is saved in my working directory. In case it’s helpful to know, running

pkgbuild::has_build_tools(debug = TRUE)

returns “TRUE”.

Does anyone have guidance they could share on how I should fix this problem?

See below for issues with catalina


Thanks for sharing this! My problem was resolved by using the clang++ installer and running the provided code.