Oh I see. Where do you have RTools installed? That is, what does Sys.getenv(“RTOOLS40_HOME”) return.
My hunch is that its installed in a folder that requires running as admin. Try openning Rtools bash ( msys2.exe) as an admin and runing the pacman command.
Backup option is to start R/RStudio as admin and running the above commands I suggested.
Now I’m running (actually I always run…) Rtools as admin and pacman -h, for example, works but pacman- Sy always returns some errors like:
:: Synchronizing package databases...
error: failed to update mingw32 (unable to lock database)
error: failed to update mingw64 (unable to lock database)
error: failed to synchronize all databases
Even if I run rm -f /var/lib/pacman/db.lck on Rtools after I get the error message above, then it gives only :: Synchronizing package databases... and does nothing.
I (1) reinstalled Rtools, (2) ran it as admin, (3) execute pacman -Sy mingw-w64-x86_64-make, (4) got :: Synchronizing package databases... without any further message or progress, (5) ran rm -f /var/lib/pacman/db.lck, (6) looped (3)–(5): nothing has changed and I’m still stuck in installing mingw32-make 😭
It’s likely in the path in R but not powershell since the .Renviron configuration temporarily adds rtools to the path during the R session but doesn’t permanently modify the environment variable
Something weird happened and running Powershell via RStudio (i.e. Powershell as admin in the Terminal pane of the RStudio, not the original Powershell) saved me. I was able to download and deploy mingw-w64-x86_64-make-4.2.1-2 on C:\rtools40\var\lib\pacman\local. And Powershell in the Terminal pane successfully recognize mingw32-make command and mingw32-make --version returns:
GNU Make 4.2.1
Built for x86_64-w64-mingw32
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <[http://gnu.org/licenses/gpl.html](http://gnu.org/licenses/gpl.html?fbclid=IwAR0Xt67tI-Km9Q59XhHilVJhgFM00OkZ9_mUB1hdsvWTsgMoeoWBJ2Om_Qk)>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Although Rtools Bash (msys2.exe) and the original Powershell do not recognize mingw32-make.exe (i.e. both fails to find the mingw32-make command), now I succeeded in running all codes in https://mc-stan.org/cmdstanr/articles/cmdstanr.html
So, for me, at least, executing the codes you suggested here in Powershell from RStudio’s Terminal pane is the key to solve! Again, thank you for your assistance!
Something weird happened and running Powershell via RStudio (i.e. Powershell as admin in the Terminal pane of the RStudio, not the original Powershell) saved me. I was able to download and deploy mingw-w64-x86_64-make-4.2.1-2 on C:\rtools40\var\lib\pacman\local. And Powershell in the Terminal pane successfully recognize mingw32-make command and mingw32-make --version returns:
GNU Make 4.2.1
Built for x86_64-w64-mingw32
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <[http://gnu.org/licenses/gpl.html](http://gnu.org/licenses/gpl.html?fbclid=IwAR0Xt67tI-Km9Q59XhHilVJhgFM00OkZ9_mUB1hdsvWTsgMoeoWBJ2Om_Qk)>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Although Rtools Bash (msys2.exe) and the original Powershell do not recognize mingw32-make.exe (i.e. both fails to find the mingw32-make command), now I succeeded in running all codes in https://mc-stan.org/cmdstanr/articles/cmdstanr.html
So, for me, at least, executing the codes you suggested here in Powershell from RStudio’s Terminal pane is the key to solve! Again, thank you for your kind assistance!
adds the Rtools folders in your path only when running R and not otherwise. If you would want to run mingw32-make in the PowerShell you would have to add this to the PATH of Windows.
But if you will only use cmdstan via cmdstanr then this is not required.