Cmdstanr can't find makefile after installation...suspect network path problem

Well, after successfully installing cmdstanr on my work windows 10, I’m having issues with the path. I suspect it has something to do with my path directory being a network drive.

When I try to run the following code, f, and fit are correctly created

library(rethinking)

f <- alist(
  y ~ dnorm( mu , sigma ),
  mu ~ dnorm( 0 , 10 ),
  sigma ~ dexp( 1 )
)

fit <- quap( 
  f , 
  data=list(y=c(-1,1)) , 
  start=list(mu=0,sigma=1)
)

But when I run the following:

fit_stan <- ulam( f , data=list(y=c(-1,1)) )

I get the following error:

Error: CmdStan path has not been set yet. See ?set_cmdstan_path.

The path is set, however (actually…this wasn’t the error I was receiving after installation…I didn’t capture the error but it was something like cmdstan couldn’t find the right makefile).

file.path(Sys.getenv(“HOME”), “.cmdstan”)
[1] “//S-N-NSCHOME/nschomes/UID/Documents/.cmdstan”

That directory contains the directory cmdstan-2.31.0, which contains the makefile.

I suspect it has something to do with that location being on the network.

I have access to the C:drive, but I’m not sure how to force install_cmdstan to go there.

I have read a lot of these sorts of struggles but none seem to be what I need. Advice is appreciated

I realize the question is stale, but in the future when you run into this issue (or if you’re still struggling with it) you can run cmdstanr::set_cmdstan_path() and get the path that is currently set.

Since the function is just in plain R you can also run cmdstanr::set_cmdstan_path (without parens) and you’ll get the R code for the checks that cmdstanr is actually running to see if the directory is valid.

If you set options(error=recover) before your ulam call you should get a backtrace that tells you if it’s a cmdstanr function that fails to find the directory or something from ulam itself… I’m not familiar with ulam.

2 Likes

Following up as I am having the same issue.

After installation of cmdstan I received the following error:

Can't find CmdStan makefile to detect version number. Path may not point to valid installation.

At this point cmdstan_path() points to valid path but repeats the above error message.
Using set_cmdstan_path() sets to the current path but does not fix the makefile error.

Running the ulam() function results in following error message as mentioned in original post:

Error: CmdStan path has not been set yet. See ?set_cmdstan_path.

Setting options(error=recover) before running the ulam() functions results in the following:

Enter a frame number, or 0 to exit   

1: ulam(alist(pulled_left ~ dbinom(1, p), logit(p) <- a[actor] + b[treatment],
2: cmdstan_model(stan_file = filex[[1]], compile = filex[[3]], cpp_options = c
3: cmdstan_version()
4: stop_no_path()

Frame number 1 is the code for a statistical model and doesn’t identify a debug location.

Frame 2 is as follows:

 function (stan_file = NULL, exe_file = NULL, compile = TRUE, 
  ...) 
{
  if (cmdstan_version() < "2.27.0" && !is.null(exe_file)) {
    stop("'exe_file' argument is only supported with CmdStan 2.27 and newer.", 
      call. = FALSE)
  }
  if (is.null(exe_file) && is.null(stan_file)) {
    stop("Unable to create a `CmdStanModel` object. Both 'stan_file' and 'exe_file' are undefined.", 
      call. = FALSE)
  }
  CmdStanModel$new(stan_file = stan_file, exe_file = exe_file, 
    compile = compile, ...)
}

Debug location highlighted as 'cmdstan_version() <` .

Frame 3 is:

function (error_on_NA = TRUE) 
{
  version <- .cmdstanr$VERSION
  if (is.null(version) && error_on_NA) {
    stop_no_path()
  }
  version
}

With ‘stop_no_path()’ highlighted as debug location.

And frame 4 is:

function () 
{
  stop("CmdStan path has not been set yet. See ?set_cmdstan_path.", 
    call. = FALSE)
}

With

stop("CmdStan path has not been set yet. See ?set_cmdstan_path.", 
    call. = FALSE)

highlighted.

I don’t really know how to interpret this other than the cmdstan_version function errors as the stan_file and exe_file cannot be found for some reason? Any advice on how to proceed in troubleshooting this further? Thanks for your advice so far.

Any advice on solving this? I’m having the same issue.