@@ -570,7 +570,7 @@ compile <- function(quiet = TRUE,
570570 }
571571
572572 if (! force_recompile ) {
573- if (interactive ()) {
573+ if (rlang :: is_interactive ()) {
574574 message(" Model executable is up to date!" )
575575 }
576576 private $ cpp_options_ <- cpp_options
@@ -581,7 +581,7 @@ compile <- function(quiet = TRUE,
581581 self $ exe_file(exe )
582582 return (invisible (self ))
583583 } else {
584- if (interactive ()) {
584+ if (rlang :: is_interactive ()) {
585585 message(" Compiling Stan program..." )
586586 }
587587 }
@@ -632,89 +632,92 @@ compile <- function(quiet = TRUE,
632632
633633 stancflags_val <- paste0(" STANCFLAGS += " , stancflags_val , paste0(" " , stancflags_combined , collapse = " " ))
634634
635- if (dry_run ) {
636- return (invisible (self ))
637- }
635+ if (! dry_run ) {
638636
639- if (compile_standalone ) {
640- expose_stan_functions(self $ functions , ! quiet )
641- }
637+ if (compile_standalone ) {
638+ expose_stan_functions(self $ functions , ! quiet )
639+ }
642640
643- withr :: with_path(
644- c(
645- toolchain_PATH_env_var(),
646- tbb_path()
647- ),
648- run_log <- wsl_compatible_run(
649- command = make_cmd(),
650- args = c(wsl_safe_path(tmp_exe ),
651- cpp_options_to_compile_flags(cpp_options ),
652- stancflags_val ),
653- wd = cmdstan_path(),
654- echo = ! quiet || is_verbose_mode(),
655- echo_cmd = is_verbose_mode(),
656- spinner = quiet && interactive() && ! identical(Sys.getenv(" IN_PKGDOWN" ), " true" ),
657- stderr_callback = function (x , p ) {
658- if (! startsWith(x , paste0(make_cmd(), " : *** No rule to make target" ))) {
659- message(x )
660- }
661- if (grepl(" PCH file" , x ) || grepl(" precompiled header" , x ) || grepl(" .hpp.gch" , x ) ) {
662- warning(
663- " CmdStan's precompiled header (PCH) files may need to be rebuilt.\n " ,
664- " If your model failed to compile please run rebuild_cmdstan().\n " ,
665- " If the issue persists please open a bug report." ,
666- call. = FALSE
667- )
668- }
669- if (grepl(" No space left on device" , x ) || grepl(" error in backend: IO failure on output stream" , x )) {
670- warning(
671- " The C++ compiler ran out of disk space and was unable to build the executables for your model!\n " ,
672- " See the above error for more details." ,
673- call. = FALSE
674- )
675- }
676- if (os_is_macos()) {
677- if (R.version $ arch == " aarch64"
678- && grepl(" but the current translation unit is being compiled for target" , x )) {
641+ withr :: with_path(
642+ c(
643+ toolchain_PATH_env_var(),
644+ tbb_path()
645+ ),
646+ run_log <- wsl_compatible_run(
647+ command = make_cmd(),
648+ args = c(wsl_safe_path(tmp_exe ),
649+ cpp_options_to_compile_flags(cpp_options ),
650+ stancflags_val ),
651+ wd = cmdstan_path(),
652+ echo = ! quiet || is_verbose_mode(),
653+ echo_cmd = is_verbose_mode(),
654+ spinner = quiet && rlang :: is_interactive() && ! identical(Sys.getenv(" IN_PKGDOWN" ), " true" ),
655+ stderr_callback = function (x , p ) {
656+ if (! startsWith(x , paste0(make_cmd(), " : *** No rule to make target" ))) {
657+ message(x )
658+ }
659+ if (grepl(" PCH file" , x ) || grepl(" precompiled header" , x ) || grepl(" .hpp.gch" , x ) ) {
679660 warning(
680- " The C++ compiler has errored due to incompatibility between the x86 and " ,
681- " Apple Silicon architectures.\n " ,
682- " If you are running R inside an IDE (RStudio, VSCode, ...), " ,
683- " make sure the IDE is a native Apple Silicon app.\n " ,
661+ " CmdStan's precompiled header (PCH) files may need to be rebuilt.\n " ,
662+ " If your model failed to compile please run rebuild_cmdstan().\n " ,
663+ " If the issue persists please open a bug report." ,
684664 call. = FALSE
685665 )
686666 }
687- }
688- },
689- error_on_status = FALSE
690- )
691- )
692- if (is.na(run_log $ status ) || run_log $ status != 0 ) {
693- stop(" An error occured during compilation! See the message above for more information." ,
694- call. = FALSE )
695- }
696- if (file.exists(exe )) {
697- file.remove(exe )
698- }
699- file.copy(tmp_exe , exe , overwrite = TRUE )
700- if (os_is_wsl()) {
701- res <- processx :: run(
702- command = " wsl" ,
703- args = c(" chmod" , " +x" , wsl_safe_path(exe )),
704- error_on_status = FALSE
667+ if (grepl(" No space left on device" , x ) || grepl(" error in backend: IO failure on output stream" , x )) {
668+ warning(
669+ " The C++ compiler ran out of disk space and was unable to build the executables for your model!\n " ,
670+ " See the above error for more details." ,
671+ call. = FALSE
672+ )
673+ }
674+ if (os_is_macos()) {
675+ if (R.version $ arch == " aarch64"
676+ && grepl(" but the current translation unit is being compiled for target" , x )) {
677+ warning(
678+ " The C++ compiler has errored due to incompatibility between the x86 and " ,
679+ " Apple Silicon architectures.\n " ,
680+ " If you are running R inside an IDE (RStudio, VSCode, ...), " ,
681+ " make sure the IDE is a native Apple Silicon app.\n " ,
682+ call. = FALSE
683+ )
684+ }
685+ }
686+ },
687+ error_on_status = FALSE
688+ )
705689 )
706- }
690+ if (is.na(run_log $ status ) || run_log $ status != 0 ) {
691+ stop(" An error occured during compilation! See the message above for more information." ,
692+ call. = FALSE )
693+ }
694+ if (file.exists(exe )) {
695+ file.remove(exe )
696+ }
697+ file.copy(tmp_exe , exe , overwrite = TRUE )
698+ if (os_is_wsl()) {
699+ res <- processx :: run(
700+ command = " wsl" ,
701+ args = c(" chmod" , " +x" , wsl_safe_path(exe )),
702+ error_on_status = FALSE
703+ )
704+ }
705+ } # End - if(!dry_run)
706+
707707 private $ exe_file_ <- exe
708708 private $ cpp_options_ <- cpp_options
709709 private $ precompile_cpp_options_ <- NULL
710710 private $ precompile_stanc_options_ <- NULL
711711 private $ precompile_include_paths_ <- NULL
712712 private $ model_methods_env_ <- new.env()
713- suppressWarnings(private $ model_methods_env_ $ hpp_code_ <- readLines(private $ hpp_file_ , warn = FALSE ))
714- if (compile_model_methods ) {
715- expose_model_methods(env = private $ model_methods_env_ ,
716- verbose = ! quiet ,
717- hessian = compile_hessian_method )
713+
714+ if (! dry_run ) {
715+ suppressWarnings(private $ model_methods_env_ $ hpp_code_ <- readLines(private $ hpp_file_ , warn = FALSE ))
716+ if (compile_model_methods ) {
717+ expose_model_methods(env = private $ model_methods_env_ ,
718+ verbose = ! quiet ,
719+ hessian = compile_hessian_method )
720+ }
718721 }
719722 invisible (self )
720723}
@@ -876,7 +879,7 @@ check_syntax <- function(pedantic = FALSE,
876879 wd = cmdstan_path(),
877880 echo = is_verbose_mode(),
878881 echo_cmd = is_verbose_mode(),
879- spinner = quiet && interactive (),
882+ spinner = quiet && rlang :: is_interactive (),
880883 stderr_callback = function (x , p ) {
881884 message(x )
882885 },
0 commit comments