Cmdstan install error

Hi, I have recently been in receipt of a new laptop and have been trying to install cmdstan and have run into an issue. My environment is

Win10 enterprise (but with admin priviliges)
R version 4.3.2
Rstudio 2023.12.1 build 402
Rtools 4.3

I downloaded and installed cmdstanr (v 0.7.1) and then ran

>check_cmdstan_toolchain(fix=TRUE)
Installing mingw32-make and g++ with Rtools43
The C++ toolchain required for CmdStan is setup properly!

Then after a call to install_cmdstan() ended up with ( I did this a couple of times, hence the flag 'overwrite = TRUE)

>install_cmdstan(overwrite = TRUE)
The C++ toolchain required for CmdStan is setup properly!
trying URL 'https://api.github.com/repos/stan-dev/cmdstan/releases/latest'
Content type 'application/json; charset=utf-8' length 14894 bytes (14 KB)
downloaded 14 KB

* Latest CmdStan release is v2.34.1
* Installing CmdStan v2.34.1 in \\internal.vic.gov.au\DEPI\HomeDirs1\DR01\Documents/.cmdstan/cmdstan-2.34.1
* Downloading cmdstan-2.34.1.tar.gz from GitHub...
* Removing the existing installation of CmdStan...
trying URL 'https://github.com/stan-dev/cmdstan/releases/download/v2.34.1/cmdstan-2.34.1.tar.gz'
Content type 'application/octet-stream' length 51577679 bytes (49.2 MB)
downloaded 49.2 MB

* Download complete
* Unpacking archive...
* Building CmdStan binaries...
expr: syntax error: unexpected argument '8'
INFO: Could not find files for the given pattern(s).
cp bin/windows-stanc bin/stanc.exe
g++ -pipe   -m64 -D_REENTRANT  -O3 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -DNO_FPRINTF_OUTPUT   -D_USE_MATH_DEFINES  -O3  -c -x c -include stan/lib/stan_math/lib/sundials_6.1.1/include/stan_sundials_printf_override.hpp stan/lib/stan_math/lib/sundials_6.1.1/src/nvector/serial/nvector_serial.c -o stan/lib/stan_math/lib/sundials_6.1.1/src/nvector/serial/nvector_serial.o
mingw32-make: *** [stan/lib/stan_math/make/libraries:64: stan/lib/stan_math/lib/sundials_6.1.1/src/nvector/serial/nvector_serial.o] Error -1073741515
mingw32-make: *** Waiting for unfinished jobs....

Warning message:
There was a problem during installation. See the error message(s) above. 

I have tried a few things on the forum and it seems to be similar to this issue
[Error installing cmdstan 2.32.1 with R4.3 Rtools43]

but not sure of the solution. Any help much appreciated!

regards
Dave

This can happen when installing to a network drive (\\internal.vic.gov.au\), try setting the installation directory to somewhere on your local computer

Hi Andrew, Yes I had already tried that…

install_cmdstan(dir="C:/users/dr01")
The C++ toolchain required for CmdStan is setup properly!
trying URL 'https://api.github.com/repos/stan-dev/cmdstan/releases/latest'
Content type 'application/json; charset=utf-8' length 14894 bytes (14 KB)
downloaded 14 KB

* Latest CmdStan release is v2.34.1
* Installing CmdStan v2.34.1 in C:/users/dr01/cmdstan-2.34.1
* Downloading cmdstan-2.34.1.tar.gz from GitHub...
trying URL 'https://github.com/stan-dev/cmdstan/releases/download/v2.34.1/cmdstan-2.34.1.tar.gz'
Content type 'application/octet-stream' length 51577679 bytes (49.2 MB)
downloaded 49.2 MB

* Download complete
* Unpacking archive...
* Building CmdStan binaries...
expr: syntax error: unexpected argument '8'
INFO: Could not find files for the given pattern(s).
cp bin/windows-stanc bin/stanc.exe
g++ -pipe   -m64 -D_REENTRANT  -O3 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -DNO_FPRINTF_OUTPUT   -D_USE_MATH_DEFINES  -O3  -c -x c -include stan/lib/stan_math/lib/sundials_6.1.1/include/stan_sundials_printf_override.hpp stan/lib/stan_math/lib/sundials_6.1.1/src/nvector/serial/nvector_serial.c -o stan/lib/stan_math/lib/sundials_6.1.1/src/nvector/serial/nvector_serial.o
mingw32-make: *** [stan/lib/stan_math/make/libraries:64: stan/lib/stan_math/lib/sundials_6.1.1/src/nvector/serial/nvector_serial.o] Error -1073741515
mingw32-make: *** Waiting for unfinished jobs....

Hi again, I tried installing cmdstan from the R window gui (so not rstudio) and then started seeing a compiler error

“libgcc_s_seh-1.dll was not found. Rinstalling the program may fix this problem”

So looks like a library is missing from my Rtools install?

Dave

Hmm that’s an odd one. I just tried a fresh R, RTools, and cmdstanr install and all worked without issue.

What version of RTools43 do you have installed? You can check by running:

readLines(file.path(Sys.getenv("RTOOLS43_HOME"),"x86_64-w64-mingw32.static.posix",".version"))

The current version should return “5958”.

If your version is lower than that, then the next step would be to uninstall rtools and download the latest version

Apologies for the delayed response. Its summer here and the weekend beckoned…

My Rtools is indeed version “5958”

To me it looks like there are a bunch of *.dll’s missing from rtools43/ucrt64/bin (all of them actually) which suggests something went awry during package installation. Might need some Rtools bash wizardry…

Ok. after uninstalling and re-installing Rtools43 on another drive (“D:\rtools43” instead of “C:\rtool43”, all the missing *.dlls and other bits magically appeared. As a result, cmdstan now installs and compiles successfully. This was obviously a local problem on my managed laptop, probably related to an overzealous security app. Seems having admin priviliges isn’t what it used to be…

Thanks for the initial help. The tip about changing installation directories was useful.

cheers
Dave

1 Like