@@ -650,10 +650,11 @@ compile <- function(quiet = TRUE,
650650 if (stancflags_local != " " ) {
651651 stancflags_combined <- c(stancflags_combined , stancflags_local )
652652 }
653- stancflags_standalone <- c(" --standalone-functions" , stancflags_val , stancflags_combined )
653+ stanc_inc_paths <- include_paths_stanc3_args(include_paths , standalone_call = TRUE )
654+ stancflags_standalone <- c(" --standalone-functions" , stanc_inc_paths , stancflags_combined )
654655 self $ functions $ hpp_code <- get_standalone_hpp(temp_stan_file , stancflags_standalone )
655656 private $ model_methods_env_ <- new.env()
656- private $ model_methods_env_ $ hpp_code_ <- get_standalone_hpp(temp_stan_file , c(stancflags_val , stancflags_combined ))
657+ private $ model_methods_env_ $ hpp_code_ <- get_standalone_hpp(temp_stan_file , c(stanc_inc_paths , stancflags_combined ))
657658 self $ functions $ external <- ! is.null(user_header )
658659 self $ functions $ existing_exe <- FALSE
659660
@@ -2337,20 +2338,27 @@ cpp_options_to_compile_flags <- function(cpp_options) {
23372338 cpp_built_options
23382339}
23392340
2340- include_paths_stanc3_args <- function (include_paths = NULL ) {
2341+ include_paths_stanc3_args <- function (include_paths = NULL , standalone_call = FALSE ) {
23412342 stancflags <- NULL
23422343 if (! is.null(include_paths )) {
23432344 assert_dir_exists(include_paths , access = " r" )
23442345 include_paths <- sapply(absolute_path(include_paths ), wsl_safe_path )
2345- paths_w_space <- grep(" " , include_paths )
2346- include_paths [paths_w_space ] <- paste0(" '" , include_paths [paths_w_space ], " '" )
2346+ # Calling stanc3 directly through processx::run does not need quoting
2347+ if (! isTRUE(standalone_call )) {
2348+ paths_w_space <- grep(" " , include_paths )
2349+ include_paths [paths_w_space ] <- paste0(" '" , include_paths [paths_w_space ], " '" )
2350+ }
23472351 include_paths <- paste0(include_paths , collapse = " ," )
23482352 if (cmdstan_version() > = " 2.24" ) {
23492353 include_paths_flag <- " --include-paths="
23502354 } else {
23512355 include_paths_flag <- " --include_paths="
23522356 }
2353- stancflags <- paste0(stancflags , include_paths_flag , include_paths )
2357+ if (isTRUE(standalone_call )) {
2358+ stancflags <- c(stancflags , " --include-paths" , include_paths )
2359+ } else {
2360+ stancflags <- paste0(stancflags , include_paths_flag , include_paths )
2361+ }
23542362 }
23552363 stancflags
23562364}
0 commit comments