@@ -253,14 +253,6 @@ cmdstan_default_path <- function(dir = NULL) {
253253
254254latest_cmdstan_installed <- function (installs_path ) {
255255 cmdstan_installs <- list.dirs(path = installs_path , recursive = FALSE , full.names = FALSE )
256- # if installed in cmdstan folder with no version move to cmdstan-version folder
257- if (" cmdstan" %in% cmdstan_installs ) {
258- ver <- read_cmdstan_version(file.path(installs_path , " cmdstan" ))
259- old_path <- file.path(installs_path , " cmdstan" )
260- new_path <- file.path(installs_path , paste0(" cmdstan-" , ver ))
261- file.rename(old_path , new_path )
262- cmdstan_installs <- list.dirs(path = installs_path , recursive = FALSE , full.names = FALSE )
263- }
264256 latest_cmdstan <- " "
265257 if (length(cmdstan_installs ) > 0 ) {
266258 cmdstan_installs <- grep(" ^cmdstan-" , cmdstan_installs , value = TRUE )
@@ -282,15 +274,18 @@ latest_cmdstan_installed <- function(installs_path) {
282274# ' @return Version number as a string.
283275read_cmdstan_version <- function (path ) {
284276 makefile_path <- file.path(path , " makefile" )
285- if (! file.exists(makefile_path )) {
277+ makefile <- tryCatch(
278+ suppressWarnings(readLines(makefile_path , warn = FALSE )),
279+ error = function (e ) NULL
280+ )
281+ if (is.null(makefile )) {
286282 warning(
287283 " Can't find CmdStan makefile to detect version number. " ,
288284 " Path may not point to valid installation." ,
289285 call. = FALSE
290286 )
291287 return (NULL )
292288 }
293- makefile <- readLines(makefile_path )
294289 version_line <- grep(" ^CMDSTAN_VERSION :=" , makefile , value = TRUE )
295290 if (length(version_line ) == 0 ) {
296291 stop(" CmdStan makefile is missing a version number." , call. = FALSE )
0 commit comments