Problem with installing cmdstanr

Dear stan community,
I was installed cmdstanr package on Windows 10, but I couldn’t run with it and encountered with the following error in cmdstanr after executing following command:

file <-file.path(cmdstan_path(),“examples/bernoulli/bernoulli.stan”)
mod ← cmdstan_model(file)

"
Error in initialize(…) :
Assertion on ‘stan_file’ failed: File does not exist: ‘C:/Users/nazari951/Documents/.cmdstan/cmdstan-2.28.2/examples/bernoulli/bernoulli.stan’.
".

Do you have any recommendation to solve this issue @andrjohns and @rok_cesnovar?

Thank you in advance!

Can you try running:

check_cmdstan_toolchain(fix=TRUE)
install_cmdstan(overwrite = TRUE)

Thanks a ton for your help @andrjohns. I ran these commands, but I got the same above-mentioned error.

check_cmdstan_toolchain(fix=TRUE)

The C++ toolchain required for CmdStan is setup properly!

install_cmdstan(overwrite = TRUE)

The C++ toolchain required for CmdStan is setup properly!

  • Latest CmdStan release is v2.28.2
  • Installing CmdStan v2.28.2 in C:/Users/nazari951/Documents/.cmdstan/cmdstan-2.28.2
  • Downloading cmdstan-2.28.2.tar.gz from GitHub…
  • Removing the existing installation of CmdStan…
  • Download complete
  • Unpacking archive…
    src/cmdstan/command.hpp: truncated gzip input
    tar.exe: Error exit delayed from previous errors.
    Error: Problem extracting tarball. Exited with return code: 1
    In addition: Warning message:
    In utils::untar(dest_file, exdir = dir_cmdstan, extras = “–strip-components 1”) :
    ‘tar.exe -xf “C:/Users/nazari951/Documents/.cmdstan/cmdstan-2.28.2.tar.gz” -C “C:/Users/nazari951/Documents/.cmdstan/cmdstan-2.28.2” --strip-components 1’ returned error code 1

file ← file.path(cmdstan_path(),“examples/bernoulli/bernoulli.stan”)
mod ← cmdstan_model(file)

Error in initialize(…) :
Assertion on ‘stan_file’ failed: File does not exist: ‘C:/Users/nazari951/Documents/.cmdstan/cmdstan-2.28.2/examples/bernoulli/bernoulli.stan’.

Kind regards,
Eisa

Can you go in that folder and see if the file actually exists?

Thank you very much @rok_cesnovar for helping. I check this folder (‘C:/Users/nazari951/Documents/.cmdstan/cmdstan-2.28.2/examples/bernoulli/bernoulli.stan’) and the examples’ folder is empty.

Regards,
Eisa

This part is a bit weird and would suggest that the file was not downloaded properly.

Can you try to download https://github.com/stan-dev/cmdstan/releases/download/v2.28.2/cmdstan-2.28.2.tar.gz and untar it manually to C:/Users/nazari951/Documents/.cmdstan/cmdstan-2.28.2

Be sure to unzip/untar it in a way that the examples is in that folder directly. So C:/Users/nazari951/Documents/.cmdstan/cmdstan-2.28.2/examples should exist.

Once you do that, run rebuild_cmdstan()

I will report back after running with it, thank you so much @rok_cesnovar for your time and help. When I run a pedantic check, I got the following error:

stan_file_pedantic <- write_stan_file("
data {
  int N;
  int y[N];
}
parameters {
  // should have <lower=0> but omitting to demonstrate pedantic mode
  real lambda;
}
model {
  y ~ poisson(lambda);
}
")
.```

mod_pedantic <- cmdstan_model(stan_file_pedantic, pedantic = TRUE)

Compiling Stan program...
makefile:139: make/command: No such file or directory

Error: An error occured during compilation! See the message above for more information.

Warm regards,
 Eisa

Yeah, this is the same reason behind this. The install_cmdstan has failed. Either the .tar.gz file that was downloaded was not downloaded correctly (network error or something) or maybe you ran out out disk space?

Dear Rok @rok_cesnovar,

My problem was solved by downloading https://github.com/stan-dev/cmdstan/releases/download/v2.28.2/cmdstan-2.28.2.tar.gz , thanks for the support!

Regards,
Eisa

1 Like

Hi all,
I want to run my model for simulated data in the cmdstanr with 50 iterations. But, I got an error during the execution (after iterations=30).
Will you help me @rok_cesnovar and @andrjohns? I will appreciate any help.
Can you help me to solve this problem @rok_cesnovar and @andrjohns? Any recommendations to solve this error would be appreciated.

"
Model executable is up to date!
Running MCMC with 1 chain…
Chain 1 Rejecting initial value:
Chain 1 Log probability evaluates to log(0), i.e. negative infinity.
Chain 1 Stan can’t start sampling from this initial value.
Chain 1 Initialization failed.
Warning: Chain 1 finished unexpectedly!
Error: No chains finished successfully. Unable to retrieve the draws.
In addition: Warning message:
Error: No chains finished successfully. Unable to retrieve the draws.
".

Can anyone help me to solve this problem?

Thank you in advance!

This seems like an issue with the model. I would recommend opening another topic and sharing the model if possible.

Sure, thank you very much for your reply and help @rok_cesnovar.