Just to clarify,
Do you have anything in your:
~/.Rprofile
, ~/.Renviron
, or ~/.R/Makevars
files? If so, what are they?
My guess is, you have something in ~/.Renviron
and shouldn’t.
Just to clarify,
Do you have anything in your:
~/.Rprofile
, ~/.Renviron
, or ~/.R/Makevars
files? If so, what are they?
My guess is, you have something in ~/.Renviron
and shouldn’t.
I’m running into Stan compilation errors using R 4.0 on Catalina. After doing a full uninstall and reinstall of R via homebrew, and installing the latest rmacoslib/r-macos-rtools, I was able to build rstan from source. However, this code (from Rethinking)
library(rethinking)
data("Trolley")
d <- Trolley
m11.1stan <- map2stan(
alist(
response ~ dordlogit(phi, cutpoints),
phi <- 0,
cutpoints ~ dnorm(0, 10)
), data= list(response = d$response),
start = list(cutpoints = c(-2, -1, 0, 1, 2, 2.5)),
chains = 2
)
Returns this error:
[1] “Error in sampler$call_sampler(args_list[[i]]) : " " c++ exception (unknown reason)”
error occurred during calling the sampler; sampling not done
Stan model ‘3c90bc124a98feb7f95b344e406697bc’ does not contain samples.
Error in names(coef) <- names(start[[1]]) :
attempt to set an attribute on NULL
I get the same error with a blank Makevars file and with @torkar’s Makevars (copied with a slight modification just based on which version of x86_64-apple-darwin lives in the gcc folder):
FC = /usr/local/gfortran/bin/gfortran
FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm
CXX14FLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function
One notable difference is that, while I know I have gcc/g++ version 9 and clang/clang++ version 11 installed, g++ --version does not return what others have said it’s supposed to:
g++ (GCC) 4.9.2 20141029 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Which is obviously wrong, but I’m not sure how to convince my computer that it has newer compilers it should be using (fwiw, when I build packages, R does seem to be calling gcc 9).
Thoughts?
On Macs with R 4.0.x, use the clang++
that comes with Xcode. If someone else figures out how to get it to work with any other compiler, great, but I don’t know how.
I put this in Makevars and confirmed that R’s calling clang++ as its compiler, but I get the same error when I run the rethinking vignette:
CC=clang
CXX=clang++
CXX11=clang++
CXX14=clang++
CXX17=clang++
CXX20=clang++
It needs to specifically be the clang++
from Xcode rather than LLVM. If you do Sys.which("clang++")
it should say /usr/bin/clang++
.
That’s the file path it comes back with, so I think I’m calling the right one.
Sys.which(“clang++”)
clang++
“/usr/bin/clang++”
Have you all heard the latest news: https://9to5mac.com/2020/06/22/arm-mac-apple/
And system2("R", "CMD config CXX14")
?