I am getting an error on different systems (Mac/Linux) when trying to use expose_stan_functions with an ..._lp function.
Description:
A simple example is pasted below. The code works with version 2.21.8 but not 2.26.23.
Reproducible Steps:
library("rstan")
#> Loading required package: StanHeaders
#>
#> rstan version 2.26.23 (Stan version 2.26.1)
#> For execution on a local, multicore CPU with excess RAM we recommend calling
#> options(mc.cores = parallel::detectCores()).
#> To avoid recompilation of unchanged Stan programs, we recommend calling
#> rstan_options(auto_write = TRUE)
#> For within-chain threading using `reduce_sum()` or `map_rect()` Stan functions,
#> change `threads_per_chain` option:
#> rstan_options(threads_per_chain = 1)
## make temporary directory
tmpdir <- tempdir()
## definfe test stan function
stan_function <- 'functions{ void test() {} }'
stan_function_lp <- 'functions{ void test_lp() {} }'
## write stan function to file
writeLines(stan_function, file.path(tmpdir, "test.stan"))
writeLines(stan_function_lp, file.path(tmpdir, "test_lp.stan"))
## compile stan function
expose_stan_functions(file.path(tmpdir, "test.stan"))
message("Success")
#> Success
expose_stan_functions(file.path(tmpdir, "test_lp.stan"))
#>
#> WARNING: The tools required to build C++ code for R were not found.
#>
#> Please install Command Line Tools for XCode (or equivalent).
#> Error in expose_stan_functions(file.path(tmpdir, "test_lp.stan")): Compilation failed!
An unspecific and incorrect error about the toolchain not being present. When using show_compiler_warnings = TRUE the error is
In file included from filea3573a329a26.cpp:9:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/rstan/include/exporter.h:4:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/RcppCommon.h:169:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/Rcpp/as.h:25:
/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/Rcpp/internal/Exporter.h:31:28: error: no matching constructor for initialization of 'stan::math::accumulator<double>'
Exporter( SEXP x ) : t(x){}
Summary:
I am getting an error on different systems (Mac/Linux) when trying to use
expose_stan_functions
with an..._lp
function.Description:
A simple example is pasted below. The code works with version 2.21.8 but not 2.26.23.
Reproducible Steps:
Created on 2023-09-10 with reprex v2.0.2
Current Output:
An unspecific and incorrect error about the toolchain not being present. When using
show_compiler_warnings = TRUE
the error isExpected Output:
No error.
RStan Version:
2.26.23
R Version:
R version 4.3.1 (2023-06-16)
Operating System:
Tried OS X 13.5.1 and Ubuntu 22.04.3 LTS