@@ -85,7 +85,6 @@ cmdstan_version <- function(error_on_NA = TRUE) {
8585# number, and path to temp dir
8686.cmdstanr <- new.env(parent = emptyenv())
8787.cmdstanr $ PATH <- NULL
88- .cmdstanr $ INSTALL_FOLDER <- NULL
8988.cmdstanr $ VERSION <- NULL
9089.cmdstanr $ TEMP_DIR <- NULL
9190
@@ -110,14 +109,10 @@ stop_no_path <- function() {
110109# ' @return The installation path.
111110# ' @export
112111cmdstan_default_install_path <- function (old = FALSE ) {
113- if (! is.null( .cmdstanr $ INSTALL_FOLDER ) ) {
114- . cmdstanr$ INSTALL_FOLDER
112+ if (old ) {
113+ file.path(Sys.getenv( " HOME " ), " . cmdstanr" )
115114 } else {
116- if (old ) {
117- file.path(Sys.getenv(" HOME" ), " .cmdstanr" )
118- } else {
119- file.path(Sys.getenv(" HOME" ), " .cmdstan" )
120- }
115+ file.path(Sys.getenv(" HOME" ), " .cmdstan" )
121116 }
122117}
123118
@@ -129,11 +124,16 @@ cmdstan_default_install_path <- function(old = FALSE) {
129124# ' @export
130125# ' @keywords internal
131126# ' @param old See [cmdstan_default_install_path()].
127+ # ' @param dir Path to a custom install folder with CmdStan installations.
132128# ' @return Path to the CmdStan installation with the most recent release
133129# ' version, or `NULL` if no installation found.
134130# '
135- cmdstan_default_path <- function (old = FALSE ) {
136- installs_path <- cmdstan_default_install_path(old )
131+ cmdstan_default_path <- function (old = FALSE , dir = NULL ) {
132+ if (! is.null(dir )) {
133+ installs_path <- dir
134+ } else {
135+ installs_path <- cmdstan_default_install_path(old )
136+ }
137137 if (dir.exists(installs_path )) {
138138 cmdstan_installs <- list.dirs(path = installs_path , recursive = FALSE , full.names = FALSE )
139139 # if installed in cmdstan folder with no version move to cmdstan-version folder
0 commit comments