Cmdstanr installation problem

Hi there,

I am trying to install cmdstanr in my rstudio but everytime it get me that your path is not identified. here are the errors:

> library(cmdstanr)
This is cmdstanr version 0.5.2.1
- CmdStanR documentation and vignettes: R Interface to CmdStan • cmdstanr
- Use set_cmdstan_path() to set the path to CmdStan
- Use install_cmdstan() to install CmdStan
> library(cmdstanr)
> check_cmdstan_toolchain(fix = TRUE)
Installing mingw32-make with Rtools40.
*Error: *
Installation of the toolchain failed. Try reinstalling RTools and trying again.
If the issue persists, open a bug report at https://github.com/stan-dev/cmdstanr.
> check_cmdstan_toolchain(fix = TRUE, quiet = TRUE)
*Error: *
Installation of the toolchain failed. Try reinstalling RTools and trying again.
If the issue persists, open a bug report at https://github.com/stan-dev/cmdstanr.

havingsaid that, I could easily install it in python as cmdstanpy and it is ok there. But I cannot work with python as I had experience with r. so i want to install cmdstanr in rstudio. I have windows on my laptp and everything is new. the laptip is for my university, and i am not sure if it is the case that it does not allow me to identify the path or not. though i have the administratpr access as well for my laptop.

I will be thankful if you guys help me with this.

What version of R do you have installed and have you also installed the recommended version of RTools?

Dear Andrew

thank you for your response. I checked that my R version is R-4.1.3 which I installed it on RStudio 2022.02.3+492 “Prairie Trillium” Release.

The Rtools version is also 4.0.28 which i installed on 10.05.2022 on my laptop.

Why it can sucessfully run from anaconda but I cannot install it in rstudio. Unfortunately Anaconda does not the latest version of Rstudio becaus of that I cannot save XXX.stan files thus I cannot use cmdstanr from that platform, although its sucessfully installed there. I could also installed the cmdstanpy sucessfully however its very challanging for to shift there. I found Rstudio very sutibale for stan coding.

Can you post the outputs from:

Sys.getenv("RTOOLS40_HOME")
Sys.getenv("PATH")
readLines("~/.Renviron")

here are the reults:

Sys.getenv(“RTOOLS40_HOME”)
[1] “C:\RTOOLSFOLDER\”
Sys.getenv(“PATH”)
[1] “C:\RTOOLSFOLDER\\usr\bin;C:\Program Files\R\R-4.1.3\bin\x64;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\libnvvp;C:\Program Files\Python39\Scripts\;C:\Program Files\Python39\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\R\R-4.1.3\bin\x64\;C:\Program Files\R\R-4.1.3\bin\i386\;C:\Program Files\RStudio\bin\quarto\bin\;C:\Program Files\MATLAB\R2022a\runtime\win64;C:\Program Files\MATLAB\R2022a\bin;C:\Program Files\NVIDIA Corporation\Nsight Compute 2022.2.0\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\mmabae\AppData\Local\Microsoft\WindowsApps;”
readLines(“~/.Renviron”)
[1] “PATH="{RTOOLS40_HOME}\\usr\\bin;{PATH}"”

here is the results:

Sys.getenv(“RTOOLS40_HOME”)
[1] “C:\RTOOLSFOLDER\”
Sys.getenv(“PATH”)
[1] “C:\RTOOLSFOLDER\\usr\bin;C:\Program Files\R\R-4.1.3\bin\x64;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\libnvvp;C:\Program Files\Python39\Scripts\;C:\Program Files\Python39\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\R\R-4.1.3\bin\x64\;C:\Program Files\R\R-4.1.3\bin\i386\;C:\Program Files\RStudio\bin\quarto\bin\;C:\Program Files\MATLAB\R2022a\runtime\win64;C:\Program Files\MATLAB\R2022a\bin;C:\Program Files\NVIDIA Corporation\Nsight Compute 2022.2.0\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\mmabae\AppData\Local\Microsoft\WindowsApps;”
readLines(“~/.Renviron”)
[1] “PATH="{RTOOLS40_HOME}\\usr\\bin;{PATH}"”

Have you tried closing R, reinstalling RTools, and trying again?

no i did not reinstall Rtools. should i do that?
my rstan is now working on rstudio, but i cannot install cmdstanr. does these two connected?

Yes reinstalling RTools is a good first step (it’s what the error messages above recommended as well). Let me know if that doesn’t help and then we can continue debugging

Dear Andrew

I reinstall rtools, r, and rstudio and after than I tried to install cmdstanr from the direction mentioned in stan website:

R Interface to CmdStan • cmdstanr (mc-stan.org)

again i received the same error as:

library(cmdstanr)
This is cmdstanr version 0.5.2.1

check_cmdstan_toolchain(fix = TRUE, quiet = TRUE)
Error:
Installation of the toolchain failed. Try reinstalling RTools and trying again.
If the issue persists, open a bug report at GitHub - stan-dev/cmdstanr: CmdStanR: the R interface to CmdStan.

I am not sure if i should manually add the Path in the windows environment for the rtools or not. but again my rstan is working correctly

The next step is to try installing the build tools that cmdstanr needs.

Launch Rtools bash from your start menu:
Screenshot 2022-07-03 153312

Then run the command:

pacman -Syu mingw-w64-x86_64-make --noconfirm

If that runs without error, then restart R and try the check_cmdstan_toolchain call again

I just run that code from both user and administrator and it was correctly done.

however the last line in the rstudio get an error as bellow:

check_cmdstan_toolchain()
Error in check_cmdstan_toolchain() :
could not find function “check_cmdstan_toolchain”

You need to load the cmdstanr package before you can use its functions:

library(cmdstanr)
check_cmdstan_toolchain()

I tried and received these comments:

library(cmdstanr)
This is cmdstanr version 0.5.2.1

check_cmdstan_toolchain()
Error:
Rtools40 installation found but the toolchain was not installed.
Run cmdstanr::check_cmdstan_toolchain(fix = TRUE) to fix the issue.
cmdstanr::check_cmdstan_toolchain(fix = TRUE)
Installing mingw32-make with Rtools40.
Error:
Installation of the toolchain failed. Try reinstalling RTools and trying again.
If the issue persists, open a bug report at GitHub - stan-dev/cmdstanr: CmdStanR: the R interface to CmdStan.

here is the photo

Now the final step is to manually add the location of the new toolchain to the path, run:

write('PATH="${RTOOLS40_HOME}\\mingw64\\bin;${PATH}"', file = "~/.Renviron", append = TRUE)

Then restart R and try to run:

cmdstanr::install_cmdstan()

Dear Andrew, I really appreciate your time.
the first line was correctly run in the rstudio and then i restarted my R. but i again received that error message

image

cmdstanr::install_cmdstan()
Error:
Rtools40 installation found but the toolchain was not installed.
Run cmdstanr::check_cmdstan_toolchain(fix = TRUE) to fix the issue.

What is the output from:

list.files(file.path(Sys.getenv("RTOOLS40_HOME"), "usr", "bin"))

and:

list.files(file.path(Sys.getenv("RTOOLS40_HOME"), "mingw64", "bin"))

this is the output for the first command:

list.files(file.path(Sys.getenv(“RTOOLS40_HOME”), “usr”, “bin”))
[1] “[.exe” “arch.exe” “ash.exe”
[4] “autopoint” “awk.exe” “b2sum.exe”
[7] “backup” “base32.exe” “base64.exe”
[10] “basename.exe” “basenc.exe” “bash.exe”
[13] “bashbug” “bsdtar.exe” “bunzip2.exe”
[16] “bzcat.exe” “bzcmp” “bzdiff”
[19] “bzegrep” “bzfgrep” “bzgrep”
[22] “bzip2.exe” “bzip2recover.exe” “bzless”
[25] “bzmore” “c_rehash” “captoinfo.exe”
[28] “cat.exe” “chattr.exe” “chcon.exe”
[31] “checkupdates” “chgrp.exe” “chmod.exe”
[34] “chown.exe” “chroot.exe” “cksum.exe”
[37] “clear.exe” “cmd” “cmp.exe”
[40] “comm.exe” “core_perl” “cp.exe”
[43] “csplit.exe” “curl.exe” “cut.exe”
[46] “cygcheck.exe” “cygpath.exe” “cygwin-console-helper.exe”
[49] “dash.exe” “date.exe” “db_archive.exe”
[52] “db_checkpoint.exe” “db_deadlock.exe” “db_dump.exe”
[55] “db_hotbackup.exe” “db_load.exe” “db_log_verify.exe”
[58] “db_printlog.exe” “db_recover.exe” “db_replicate.exe”
[61] “db_stat.exe” “db_tuner.exe” “db_upgrade.exe”
[64] “db_verify.exe” “dd.exe” “dep-search”
[67] “df.exe” “diff.exe” “diff3.exe”
[70] “dir.exe” “dircolors.exe” “dirname.exe”
[73] “du.exe” “dumper.exe” “echo.exe”
[76] “egrep” “env.exe” “envsubst.exe”
[79] “expand.exe” “expr.exe” “factor.exe”
[82] “false.exe” “fgrep” “file.exe”
[85] “find.exe” “fmt.exe” “fold.exe”
[88] “funzip.exe” “gawk-5.1.0.exe” “gawk.exe”
[91] “gdbm_dump.exe” “gdbm_load.exe” “gdbmtool.exe”
[94] “gencat.exe” “getconf.exe” “getfacl.exe”
[97] “gettext.exe” “gettext.sh” “gettextize”
[100] “gkill.exe” “gpg-zip” “gpg.exe”
[103] “gpgsplit.exe” “gpgv.exe” “grep.exe”
[106] “groups.exe” “gunzip” “gzexe”
[109] “gzip.exe” “head.exe” “hostid.exe”
[112] “hostname.exe” “iconv.exe” “id.exe”
[115] “info.exe” “infocmp.exe” “infokey.exe”
[118] “infotocap.exe” “install-info.exe” “install.exe”
[121] “join.exe” “kill.exe” “ldd.exe”
[124] “ldh.exe” “less.exe” “lessecho.exe”
[127] “lesskey.exe” “link.exe” “ln.exe”
[130] “locale.exe” “locate.exe” “logname.exe”
[133] “ls.exe” “lsattr.exe” “lzcat.exe”
[136] “lzcmp” “lzdiff” “lzegrep”
[139] “lzfgrep” “lzgrep” “lzless”
[142] “lzma.exe” “lzmadec.exe” “lzmainfo.exe”
[145] “lzmore” “make.exe” “makeinfo”
[148] “makepkg” “makepkg-mingw” “makepkg-template”
[151] “md5sum.exe” “minidumper.exe” “mintheme”
[154] “mintty.exe” “mkdir.exe” “mkfifo.exe”
[157] “mkgroup.exe” “mknod.exe” “mkpasswd.exe”
[160] “mktemp.exe” “mount.exe” “msgattrib.exe”
[163] “msgcat.exe” “msgcmp.exe” “msgcomm.exe”
[166] “msgconv.exe” “msgen.exe” “msgexec.exe”
[169] “msgfilter.exe” “msgfmt.exe” “msggrep.exe”
[172] “msginit.exe” “msgmerge.exe” “msgunfmt.exe”
[175] “msguniq.exe” “msys-2.0.dll” “msys-asprintf-0.dll”
[178] “msys-atomic-1.dll” “msys-bz2-1.dll” “msys-charset-1.dll”
[181] “msys-crypt-0.dll” “msys-crypto-1.1.dll” “msys-curl-4.dll”
[184] “msys-db-5.3.dll” “msys-db_cxx-5.3.dll” “msys-expat-1.dll”
[187] “msys-formw6.dll” “msys-gcc_s-seh-1.dll” “msys-gdbm-6.dll”
[190] “msys-gdbm_compat-4.dll” “msys-gettextlib-0-19-8-1.dll” “msys-gettextpo-0.dll”
[193] “msys-gettextsrc-0-19-8-1.dll” “msys-gfortran-5.dll” “msys-gmp-10.dll”
[196] “msys-gmpxx-4.dll” “msys-gomp-1.dll” “msys-history8.dll”
[199] “msys-hogweed-5.dll” “msys-iconv-2.dll” “msys-intl-8.dll”
[202] “msys-lz4-1.dll” “msys-lzma-5.dll” “msys-magic-1.dll”
[205] “msys-menuw6.dll” “msys-mpfr-6.dll” “msys-ncurses++w6.dll”
[208] “msys-ncursesw6.dll” “msys-nettle-7.dll” “msys-panelw6.dll”
[211] “msys-pcre-1.dll” “msys-perl5_30.dll” “msys-quadmath-0.dll”
[214] “msys-readline8.dll” “msys-ssl-1.1.dll” “msys-stdc+±6.dll”
[217] “msys-ticw6.dll” “msys-xml2-2.dll” “msys-z.dll”
[220] “msys-zstd-1.dll” “mv.exe” “ngettext.exe”
[223] “nice.exe” “nl.exe” “nohup.exe”
[226] “nproc.exe” “numfmt.exe” “od.exe”
[229] “openssl.exe” “paccache” “pacdiff”
[232] “paclist” “paclog-pkglist” “pacman-conf.exe”
[235] “pacman-db-upgrade” “pacman-key” “pacman-rec-filename-grep”
[238] “pacman.exe” “pacscripts” “pacsearch”
[241] “pacsort.exe” “pactree.exe” “passwd.exe”
[244] “paste.exe” “patch.exe” “pathchk.exe”
[247] “pdftexi2dvi” “peflags.exe” “peflagsall”
[250] “perl.exe” “perl5.30.2.exe” “pinky.exe”
[253] “pldd.exe” “pod2texi” “pr.exe”
[256] “printenv.exe” “printf.exe” “ps.exe”
[259] “ptx.exe” “pwd.exe” “rankmirrors”
[262] “readlink.exe” “realpath.exe” “rebase.exe”
[265] “rebaseall” “recode-sr-latin.exe” “regen-info.sh”
[268] “regtool.exe” “repo-add” “repo-elephant”
[271] “repo-remove” “reset.exe” “restore”
[274] “rm.exe” “rmdir.exe” “rsync.exe”
[277] “runcon.exe” “sdiff.exe” “sed.exe”
[280] “seq.exe” “setfacl.exe” “setmetamode.exe”
[283] “sh.exe” “sha1sum.exe” “sha224sum.exe”
[286] “sha256sum.exe” “sha384sum.exe” “sha512sum.exe”
[289] “shell” “shred.exe” “shuf.exe”
[292] “site_perl” “sleep.exe” “sort.exe”
[295] “split.exe” “ssp.exe” “start”
[298] “stat.exe” “strace.exe” “stty.exe”
[301] “sum.exe” “sync.exe” “tabs.exe”
[304] “tac.exe” “tail.exe” “tar.exe”
[307] “tee.exe” “test.exe” “testpkg.exe”
[310] “texi2any” “texi2dvi” “texi2pdf”
[313] “texindex.exe” “tic.exe” “timeout.exe”
[316] “toe.exe” “touch.exe” “tput.exe”
[319] “tr.exe” “true.exe” “truncate.exe”
[322] “tset.exe” “tsort.exe” “tty.exe”
[325] “tzset.exe” “umount.exe” “uname.exe”
[328] “uncompress” “unexpand.exe” “uniq.exe”
[331] “unlink.exe” “unlzma.exe” “unxz.exe”
[334] “unzip.exe” “unzipsfx.exe” “unzstd.exe”
[337] “updatedb” “updpkgsums” “users.exe”
[340] “vdir.exe” “vendor_perl” “vercmp.exe”
[343] “wc.exe” “which.exe” “who.exe”
[346] “whoami.exe” “winpty-agent.exe” “winpty-debugserver.exe”
[349] “winpty.dll” “winpty.exe” “xargs.exe”
[352] “xgettext.exe” “xmlcatalog.exe” “xmllint.exe”
[355] “xmlwf.exe” “xz.exe” “xzcat.exe”
[358] “xzcmp” “xzdec.exe” “xzdiff”
[361] “xzegrep” “xzfgrep” “xzgrep”
[364] “xzless” “xzmore” “yes.exe”
[367] “zcat” “zcmp” “zdiff”
[370] “zegrep” “zfgrep” “zforce”
[373] “zgrep” “zip.exe” “zipcloak.exe”
[376] “zipgrep” “zipinfo.exe” “zipnote.exe”
[379] “zipsplit.exe” “zless” “zmore”
[382] “znew” “zstd.exe” “zstdcat.exe”
[385] “zstdgrep” “zstdless” “zstdmt.exe”