Error when running Rstan with update

Running on Mac, installed to Catalina
R version 3.6.3
R stan version: 2.19.3

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! In file included from <built-in>:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Dense:1:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppEigen/include/Eigen/Core:82:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/new:85:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/exception:82:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstdlib:86:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/stdlib.h:94:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:66:
In file included from /Library/Developer
In addition: Warning message:
In system(cmd, intern = !verbose) :
  running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file1247215182820.cpp 2> file1247215182820.cpp.err.txt' had status 1

Can you do

library(rstan)
example(stan_model, run.dontrun = TRUE)

and tell us the line that has error: (with the colon) in it?

Yes, thanks.

Here it is

/usr/local/include/stdint.h:7:10: fatal error: 'zzip/conf.h' file not found
#include <zzip/conf.h> 

That seems like an odd error, but when I cut and paste the output into text edit and search for “error:” that’s the only thing that comes up.

Try doing

xcode-select --install

in the Terminal app or the Terminal window of RStudio.

Yes, I tried that. I get:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

All this is after having done

?

Okay…I recently downloaded Command_Line_Tools_for_Xcode_11.4_beta_3, so as not to have the entire Xcode version. Would I just go back to that installer package and use control in the same way and then reinstall stan from source?

I found this link: https://stackoverflow.com/questions/34617452/how-to-update-xcode-from-command-line.

It looks like

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Does the trick.

Stan should be available for R 3.6.3 right? This is the output I get for install.packages(c(“StanHeaders”, “stan”), type = “source”).

Warning in install.packages :
  package ‘stan’ is not available (for R version 3.6.3)
trying URL 'https://cran.rstudio.com/src/contrib/StanHeaders_2.19.2.tar.gz'
Content type 'application/x-gzip' length 1278581 bytes (1.2 MB)
==================================================
downloaded 1.2 MB

* installing *source* package ‘StanHeaders’ ...
** package ‘StanHeaders’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -DNO_FPRINTF_OUTPUT -I"../inst/include" -include stan_sundials_printf_override.hpp  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c cvodes/cvodea.c -o cvodes/cvodea.o
In file included from cvodes/cvodea.c:29:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:66:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/wait.h:110:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/resource.h:72:
/usr/local/include/stdint.h:7:10: fatal error: 'zzip/conf.h' file not found
#include <zzip/conf.h> 
         ^~~~~~~~~~~~~
1 error generated.
make: *** [cvodes/cvodea.o] Error 1
ERROR: compilation failed for package ‘StanHeaders’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/StanHeaders’
Warning in install.packages :
  installation of package ‘StanHeaders’ had non-zero exit status

The downloaded source packages are in
‘/private/var/folders/5v/66f0x8953rn0b13jmqw36qnm0000gn/T/RtmpfpUA37/downloaded_packages’```

You can probably get the binary for StanHeaders as long as you are not using Windows

install.packages("StanHeaders", type = "mac.binary")

But your clang is still messed up. It should be utilizing /usr/local/clang7/ or something.

In my comupter, the latest Rstan works fine with the latest R on Win10.

I also encountered some error about a week ago. Then, I threw away all files related R, and reinstalled them. Then Rstan works fine :)

Sorry–do you mean you just deleted everything?

Yes!
I removed everything, including installed packages
I am beginner. If you took a lot of time for them,…please try.

Haha…thanks. Yeah, there are a ton of packages. I’ll probably wait for some others to weigh in. But if you’re already on Stan, you’re moving quick, so kudos to you.

When I run the

install.packages("StanHeaders", type = "mac.binary")

I receive the following error:

> install.packages("StanHeaders", type = "mac.binary")
Error in install.packages : Updating loaded packages
> install.packages("StanHeaders", type = "mac.binary")
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/bin/macosx/contrib/3.6:
  cannot open URL 'https://cran.rstudio.com/bin/macosx/contrib/3.6/PACKAGES'

   package ‘StanHeaders’ is available as a source package but not as a binary

Warning in install.packages :
  package ‘StanHeaders’ is not available (as a binary package for R version 3.6.3)

OK. Try

install.packages(
"https://cran.r-project.org/bin/macosx/el-capitan/contrib/3.6/StanHeaders_2.21.0-1.tgz",
repos = NULL, type = "mac.binary")

Awesome, so that downloaded it.

However, it’s still not running:
when I run the

example(stan_model, run.dontrun = TRUE)

I still get the same error as above:

/usr/local/include/stdint.h:7:10: fatal error: 'zzip/conf.h' file not found
#include <zzip/conf.h> 

Try adding

CXX14 = /usr/local/clang7/bin/clang++ -stdlib=libc++ -nostdinc++ -I/usr/local/clang7/include/c++/v1

to the bottom of ~/.R/Makevars .

Hmmm–so I didn’t have that file, but I created it the text file within the .R directory and added the code. Still not working, but there isn’t any “Error:”

The error I do get is

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: *** [file39641b876b73.o] Error 127

I’ll do a search for this on the internet as well.

I continually get this pop-up as well.
image

Thanks!

I’m looking at this thread: Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created!.

I tried installing stan from source: however, I get this error:

/bin/sh: /usr/local/clang7/bin/clang++: No such file or directory
make: *** [chains.o] Error 127
ERROR: compilation failed for package ‘rstan’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/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/5v/66f0x8953rn0b13jmqw36qnm0000gn/T/RtmpFtKGAw/downloaded_packages’

Should I alter the code within the Makevars folder?

What version of clang is in /usr/local?