Cmdstan not installing

Hi,

I’m trying to install cmdstan using cmdstanr. I am using the most up to date version of R and R studio. I have rstan, and cmdstanr installed fine.

The error that occurs after running install_cmdstan(cores = 2) is

Error: Problem extracting tarball. Exited with return code: 1

I also get the warning

In addition: Warning message:
In utils::untar(dest_file, exdir = dir_cmdstan, extras = “–strip-components 1”) :
‘tar.exe -xf “\fileserver02\Staff\lachlanW/.cmdstanr/cmdstan-2.25.0.tar.gz” -C “//fileserver02/Staff/lachlanW/.cmdstanr/cmdstan-2.25.0” --strip-components 1’ returned error code 1

This is my work computer (Windows 10), so I don’t know if it is an access issue, or I have some other global or profile variable set wrong.

Any help would be appreciated.

L

First thing to check is whether you can use the tar command, since that’s where the error is coming from. What do you get if you run:

system("tar.exe")

I get the below result

system(“tar.exe”)
tar.exe: Must specify one of -c, -r, -t, -u, -x
[1] 1

Great! Two things to check next, can you install the github version of cmdstanr:

devtools::install_github("stan-dev/cmdstanr")

And then run:

cmdstanr::check_cmdstan_toolchain(fix=TRUE)

Which will check that everything is configured and setup correctly. If there’s an error which the program corrects, try installing cmdstan again like before.

If not, and it says that everything is properly setup, then the next step is to check whether it works when you try to install cmdstan in a local folder (on your computer, rather than on the networked drive). This can be something like your Documents folder or somewhere on the C:/ drive, as long as it’s not on the networked drive. You can specify this install directory via:

install_cmdstan(cores=2, dir = new_install_dir_here)
3 Likes

hi, I have followed the steps you mentioned before, but when I run
cmdstanr::check_cmdstan_toolchain(fix=TRUE)

I got this error message:

Error:
Rtools42 was not found but is required to run CmdStan with R version 4.3.1.
Please install Rtools42 and run cmdstanr::check_cmdstan_toolchain().

But I have installed Rtools 43. Both my R and Rstudio are the newest versions. Can you help me to figure this out? Many thanks!!

@rok_cesnovar what are the CmdStanR build scripts looking for? is RTools 4.3 a problem?

Please make sure to use the latest version of cmdstanr, where Rtools 4.3 are fully supported.

remotes::install_github("stan-dev/cmdstanr")
1 Like

Thank you for your reply very much! Now I am trying to run these codes:

remotes::install_github("stan-dev/cmdstanr")
library(cmdstanr)
install_cmdstan()

But when I run install_cmdstan(), I got error message:

The C++ toolchain required for CmdStan is setup properly!
trying URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest
trying URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest
trying URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest
trying URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest
trying URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest
trying URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest
Error: GitHub download of release list failed with error: cannot open URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest

However, I can open this URL in my internet browser.

Thank you again for your help!

As when I tried install_cmdstan(), I got the error message

The C++ toolchain required for CmdStan is setup properly!
trying URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest
trying URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest
trying URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest
trying URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest
trying URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest
trying URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest
Error: GitHub download of release list failed with error: cannot open URL ‘https://api.github.com/repos/stan-dev/cmdstan/releases/latest

So I download the source code from GitHub manually, and run the code:
set_cmdstan_path("D:/R-Rstudio/cmdstan-2.32.2")

It seemed successful:

CmdStan path set to: D:/R-Rstudio/cmdstan-2.32.2

But when I try to compile a model, I got error messages as follows:

Error in process_initialize(self, private, command, args, stdin, stdout, …:
! Native call to processx_exec failed
Caused by error in chain_call(c_processx_exec, command, c(command, args), pty, pty_options, …:
! Command ‘bin/stanc.exe’ not found @win/processx.c:982 (processx_exec)
Type .Last.error to see the more details.

When I tried cmdstanr:: rebuild_cmdstan(), I got the error message

Ϣ: ṩģʽ޷ҵļ
rm -f -r test
rm -f
rm -f
rm -f
rm -f
removing dependency files
rm -f
rm -f
rm -f
mingw32-make: *** No rule to make target ‘clean-libraries’, needed by ‘clean-all’. Stop.
Ϣ: ṩģʽ޷ҵļ
mingw32-make: *** No rule to make target ‘stan/src/stan/model/model_header.hpp’, needed by ‘stan/src/stan/model/model_header.hpp.gch’. Stop.
mingw32-make: *** Waiting for unfinished jobs…

— Compiling the main object file. This might take up to a minute. —
g++ -Wno-nonnull -c -o src/cmdstan/main.o src/cmdstan/main.cpp
src/cmdstan/main.cpp:1:10: fatal error: cmdstan/command.hpp: No such file or directory
1 | #include <cmdstan/command.hpp>
| ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
mingw32-make: *** [make/program:14: src/cmdstan/main.o] Error 1

Many thanks for any possible solutions!!

Hi,
I try to install cmdstanr. I use your code system(“tar.exe”) and got the following result
system(“tar.exe”)
tar.exe: Must specify one of -c, -r, -t, -u, -x
[1] 1
However, when I use devtools::install_github(“stan-dev/cmdstanr”)
I found the following results
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace ‘rlang’ 1.0.2 is already loaded, but >= 1.0.6 is required
Could you plz me how to solve it and install cmdstanr?

Re-run devtools::install_github("stan-dev/cmdstanr") in a fresh R session. If you have further problems, let us know!

I installed cmdsstanr. However, when I try to run a model using cmdstan_model, I got the following message.
Error: CmdStan path has not been set yet. See ?set_cmdstan_path.

How do I solve this problem? How do I set a path?

My guess is that you have not installed cmdstan (which is not the same thing as cmdstanr, and is required for cmdstanr to fit models). Run cmdstanr::check_cmdstan_toolchain(). If that gives you a message saying that the toolchain is set up properly, then run cmdstanr::install_cmdstan(), which should install cmdstan and set the path automatically.

If you are certain that you have previously installed cmdstan and for some reason you don’t want to reinstall it in the default location, then you need to set the cmdstan path so that cmdstanr knows where to find cmdstan. The suggestion in the error message to check out ?set_cmdstan_path is helpful.

1 Like

Thanks for your reply.
Actually, I am trying to use cmdstan_model.
I attach an Rmd file for your kind consideration.
cmdstanr1.Rmd (228 Bytes)

Did you try following the instructions from my above post? Do you have an installation of cmdstan on your computer?

I used your previous command cmdstanr::check_cmdstan_toolchain() and I got the following message
The C++ toolchain required for CmdStan is setup properly!

When I try to install C++, I got,

Installing package into ‘C:/Users/shah_/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘C++’ is not available for this version of R

Installing package into ‘C:/Users/shah_/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘C++’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at

Note the next part of the instruction:

Many many thanks!!!

A post was split to a new topic: Kolmogorov smirnov test on model output