@@ -275,25 +275,9 @@ CmdStanModel <- R6::R6Class(
275275 if (! is.null(stan_file ) && compile ) {
276276 self $ compile(... )
277277 } else {
278- # set exe path, same logic as in compile
279- if (! is.null(private $ dir_ )){
280- dir <- repair_path(absolute_path(private $ dir_ ))
281- assert_dir_exists(dir , access = " rw" )
282- if (length(self $ exe_file()) != 0 ) {
283- self $ exe_file(file.path(dir , basename(self $ exe_file())))
284- }
285- }
286- if (length(self $ exe_file()) == 0 ) {
287- if (is.null(private $ dir_ )) {
288- exe_base <- self $ stan_file()
289- } else {
290- exe_base <- file.path(private $ dir_ , basename(self $ stan_file()))
291- }
292- self $ exe_file(cmdstan_ext(strip_ext(exe_base )))
293- if (dir.exists(self $ exe_file())) {
294- stop(" There is a subfolder matching the model name in the same folder as the model! Please remove or rename the subfolder and try again." , call. = FALSE )
295- }
296- }
278+ # resolve exe path with dir
279+ exe <- resolve_exe_path(args $ dir , private $ dir_ , self $ exe_file(), self $ stan_file())
280+ self $ exe_file(exe )
297281
298282 # exe_info is updated inside the compile method (if compile command is run)
299283 self $ exe_info(update = TRUE )
@@ -599,18 +583,6 @@ compile <- function(quiet = TRUE,
599583 include_paths <- private $ precompile_include_paths_
600584 }
601585 private $ include_paths_ <- include_paths
602- if (is.null(dir ) && ! is.null(private $ dir_ )) {
603- dir <- absolute_path(private $ dir_ )
604- } else if (! is.null(dir )) {
605- dir <- absolute_path(dir )
606- }
607- if (! is.null(dir )) {
608- dir <- repair_path(dir )
609- assert_dir_exists(dir , access = " rw" )
610- if (length(self $ exe_file()) != 0 ) {
611- private $ exe_file_ <- file.path(dir , basename(self $ exe_file()))
612- }
613- }
614586
615587 # temporary deprecation warnings
616588 if (isTRUE(threads )) {
@@ -2627,12 +2599,16 @@ model_compile_info_legacy <- function(exe_file) {
26272599 info
26282600}
26292601
2602+ <<<<<<< HEAD
26302603is_variables_method_supported <- function (mod ) {
26312604 cmdstan_version() > = " 2.27.0" && mod $ has_stan_file() && file.exists(mod $ stan_file())
26322605}
26332606resolve_exe_path <- function (
26342607 dir = NULL , private_dir = NULL , self_exe_file = NULL , self_stan_file = NULL
26352608) {
2609+ =======
2610+ resolve_exe_path <- function (dir = NULL , private_dir = NULL , self_exe_file = NULL , self_stan_file = NULL ) {
2611+ >>>>>>> d2603e27 (move exe file path resolution to separate function )
26362612 if (is.null(dir ) && ! is.null(private_dir )) {
26372613 dir <- absolute_path(private_dir )
26382614 } else if (! is.null(dir )) {
0 commit comments