Mingw32-make: *** INTERNAL: readdir: Invalid argument

I’m trying to use rethinking::ulam(), cmdstan_model(), stan(), and I get the same error “mingw32-make: *** INTERNAL: readdir: Invalid argument”

I followed the useful “Getting started with CmdStanR” page.

Rtools42 is installed at c:\rtools42

check_cmdstan_toolchain() returns “The C++ toolchain required for CmdStan is setup properly!”

cmdstan_version() returns “2.32.2”

cmdstan_path() returns “C:/Users/first-last/OneDrive - MMC/Documents/.cmdstan/cmdstan-2.32.2”

I’m using the RGui because I’ve had trouble with corporate installing RStudio on my machine. Here’s my R version:

sessionInfo()
R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] digest_0.6.31              rethinking_2.31            rstan_2.21.8               StanHeaders_2.26.27        cmdstanr_0.5.3             bayesplot_1.10.0           gridExtra_2.3              PerformanceAnalytics_2.0.4 xts_0.13.1                 zoo_1.8-12                 lubridate_1.9.2            forcats_1.0.0              stringr_1.5.0             
[14] dplyr_1.1.2                purrr_1.0.1                readr_2.1.4                tidyr_1.3.0                tibble_3.2.1               ggplot2_3.4.2              tidyverse_2.0.0           

loaded via a namespace (and not attached):
 [1] shape_1.4.6          gtable_0.3.3         tensorA_0.36.2       xfun_0.39            processx_3.8.1       inline_0.3.19        lattice_0.21-8       callr_3.7.3          tzdb_0.4.0           quadprog_1.5-8       vctrs_0.6.3          tools_4.3.1          ps_1.7.5             generics_0.1.3       stats4_4.3.1         fansi_1.0.4          pkgconfig_2.0.3     
[18] checkmate_2.2.0      distributional_0.3.2 RcppParallel_5.1.7   lifecycle_1.0.3      compiler_4.3.1       farver_2.1.1         munsell_0.5.0        codetools_0.2-19     pillar_1.9.0         crayon_1.5.2         MASS_7.3-60          abind_1.4-5          posterior_1.4.1      tidyselect_1.2.0     mvtnorm_1.2-2        stringi_1.7.12       labeling_0.4.2      
[35] grid_4.3.1           colorspace_2.1-0     cli_3.6.1            magrittr_2.0.3       loo_2.6.0            pkgbuild_1.4.2       utf8_1.2.3           withr_2.5.0          prettyunits_1.1.1    scales_1.2.1         backports_1.4.1      bit64_4.0.5          timechange_0.2.0     matrixStats_1.0.0    bit_4.0.5            hms_1.1.3            coda_0.19-4         
[52] knitr_1.43           rlang_1.1.1          Rcpp_1.0.10          glue_1.6.2           vroom_1.6.3          jsonlite_1.8.5       R6_2.5.1            
> 

Reading these forums, I’ve seen that the Windows environment “PATH” variable sometimes needs updating.

I’ve used Sys.setenv("PATH" = ...) to try differnt recommended locations, like including rtools42 instead of rtools43. When I restart R, this is what I get:

> Sys.getenv("PATH")

[1] "c:/rtools43/x86_64-w64-mingw32.static.posix/bin;c:/rtools43/usr/bin;\\usr\\bin;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\windows\\System32\\OpenSSH\\;C:\\Users\\Administrator\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files (x86)\\Adaptiva\\AdaptivaClient\\bin\\x32;C:\\Program Files (x86)\\Adaptiva\\AdaptivaClient\\bin\\x64;C:\\Program Files\\dotnet\\;C:\\Program Files\\WinZip\\;C:\\Program Files\\SASHome\\x86\\Secure\\ccme4;C:\\Program Files\\SASHome\\Secure\\ccme4;C:\\Users\\first-last\\AppData\\Local\\Microsoft\\WindowsApps;"

>

I’ve also tried running pacman -Syu mingw-w64-x86_64-make from Rtools Bash. I’m not sure what this is supposed to do, but again, I’ve been trying anything I can find, and I’m still stuck.

The part that’s confusing to me is that I can run, successfully, rstanarm::stan_glm() So I thought the other Stan-based tools would work too.

What are the chances the Stan experts can help me? Thanks!

The issue is most likely using a sub-folder of OneDrive, as spaces in the folder path are something mingw32-make cannot handle

Bingo!

I did this:

library(cmdstanr)
install_cmdstan(dir = "c:\\cmdstanr\\")
cmdstan_path()
"c:/cmdstanr/cmdstan-2.32.2"

And things started working. The model compiled, and I could see summaries, draws, and so forth.

I was stuck on this for weeks and should have posted sooner. Thank you for the quick and useful help!

2 Likes