@@ -664,54 +664,57 @@ compile <- function(quiet = TRUE,
664664 if (compile_standalone ) {
665665 expose_stan_functions(self $ functions , ! quiet )
666666 }
667-
668- withr :: with_path(
669- c(
670- toolchain_PATH_env_var(),
671- tbb_path()
672- ),
673- run_log <- wsl_compatible_run(
674- command = make_cmd(),
675- args = c(wsl_safe_path(repair_path(tmp_exe )),
676- cpp_options_to_compile_flags(cpp_options ),
677- stancflags_val ),
678- wd = cmdstan_path(),
679- echo = ! quiet || is_verbose_mode(),
680- echo_cmd = is_verbose_mode(),
681- spinner = quiet && rlang :: is_interactive() && ! identical(Sys.getenv(" IN_PKGDOWN" ), " true" ),
682- stderr_callback = function (x , p ) {
683- if (! startsWith(x , paste0(make_cmd(), " : *** No rule to make target" ))) {
684- message(x )
685- }
686- if (grepl(" PCH file" , x ) || grepl(" precompiled header" , x ) || grepl(" .hpp.gch" , x ) ) {
687- warning(
688- " CmdStan's precompiled header (PCH) files may need to be rebuilt.\n " ,
689- " If your model failed to compile please run rebuild_cmdstan().\n " ,
690- " If the issue persists please open a bug report." ,
691- call. = FALSE
692- )
693- }
694- if (grepl(" No space left on device" , x ) || grepl(" error in backend: IO failure on output stream" , x )) {
695- warning(
696- " The C++ compiler ran out of disk space and was unable to build the executables for your model!\n " ,
697- " See the above error for more details." ,
698- call. = FALSE
699- )
700- }
701- if (os_is_macos()) {
702- if (R.version $ arch == " aarch64"
703- && grepl(" but the current translation unit is being compiled for target" , x )) {
667+
668+ withr :: with_envvar(
669+ c(" HOME" = utils :: shortPathName(Sys.getenv(" HOME" ))),
670+ withr :: with_path(
671+ c(
672+ toolchain_PATH_env_var(),
673+ tbb_path()
674+ ),
675+ run_log <- wsl_compatible_run(
676+ command = make_cmd(),
677+ args = c(wsl_safe_path(repair_path(tmp_exe )),
678+ cpp_options_to_compile_flags(cpp_options ),
679+ stancflags_val ),
680+ wd = cmdstan_path(),
681+ echo = ! quiet || is_verbose_mode(),
682+ echo_cmd = is_verbose_mode(),
683+ spinner = quiet && rlang :: is_interactive() && ! identical(Sys.getenv(" IN_PKGDOWN" ), " true" ),
684+ stderr_callback = function (x , p ) {
685+ if (! startsWith(x , paste0(make_cmd(), " : *** No rule to make target" ))) {
686+ message(x )
687+ }
688+ if (grepl(" PCH file" , x ) || grepl(" precompiled header" , x ) || grepl(" .hpp.gch" , x ) ) {
704689 warning(
705- " The C++ compiler has errored due to incompatibility between the x86 and " ,
706- " Apple Silicon architectures.\n " ,
707- " If you are running R inside an IDE (RStudio, VSCode, ...), " ,
708- " make sure the IDE is a native Apple Silicon app.\n " ,
690+ " CmdStan's precompiled header (PCH) files may need to be rebuilt.\n " ,
691+ " If your model failed to compile please run rebuild_cmdstan().\n " ,
692+ " If the issue persists please open a bug report." ,
709693 call. = FALSE
710694 )
711695 }
712- }
713- },
714- error_on_status = FALSE
696+ if (grepl(" No space left on device" , x ) || grepl(" error in backend: IO failure on output stream" , x )) {
697+ warning(
698+ " The C++ compiler ran out of disk space and was unable to build the executables for your model!\n " ,
699+ " See the above error for more details." ,
700+ call. = FALSE
701+ )
702+ }
703+ if (os_is_macos()) {
704+ if (R.version $ arch == " aarch64"
705+ && grepl(" but the current translation unit is being compiled for target" , x )) {
706+ warning(
707+ " The C++ compiler has errored due to incompatibility between the x86 and " ,
708+ " Apple Silicon architectures.\n " ,
709+ " If you are running R inside an IDE (RStudio, VSCode, ...), " ,
710+ " make sure the IDE is a native Apple Silicon app.\n " ,
711+ call. = FALSE
712+ )
713+ }
714+ }
715+ },
716+ error_on_status = FALSE
717+ )
715718 )
716719 )
717720 if (is.na(run_log $ status ) || run_log $ status != 0 ) {
0 commit comments