Cmdstanr installation error: Command not found @win/processx.c:977

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.

> Sys.getenv("RTOOLS40_HOME")
[1] "C:\\rtools40"

and indeed there is my Rtools40.

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 ran your code again in my R/RStudio as admin, but I only got the same error again 😢

Can you run

rm -f /var/lib/pacman/db.lck in the rtools bash. And then try again?

This is an issue with msys2 that we havent seen before. Looks similar to https://github.com/msys2/MSYS2-packages/issues/1298

Yeah, I have done that many times but it hasn’t work… That’s why I want to know how to install mingw32-make without using pacman.

Pacman is the package manager of msys2 and I do not think you can install it some other way. Have you tried reinstalling Rtools 4.0?

OK, I will try re-installation of Rtools.

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 😭

Argh, that sounds very annoying.

And if you run

its the same?

Same after running the code you shared…

Shall I ran some codes on C:\rtools40\mingw32.exe or C:\rtools40\mingw64.exe (, or C:\rtools40\usr\bin\bash.exe as @MatsuuraKentaro suggested)?

C:\rtools40\usr\bin\bash.exe is where you run this

If you have C:\rtools40\usr\bin in you PATH you can also run it in the windows powershell

The bash doesn’t recognize either pacman or rm, and returns command not found, e.g.:

$ pacman -Syu mingw-w64-x86_64-make
bash: pacman: command not found

Powershell also does not recognize pacman.

Do you have C:\rtools40\usr\bin in the PATH environment variable.

Can you post the output of Sys.getenv(“PATH”)

I confirmed there is C:\rtools40\usr\bin in the PATH. You can also find C:\\rtools40\\usr\\bin in the followings.

Sys.getenv("PATH")
[1] "C:\\rtools40\\usr\\bin;C:\\rtools40\\mingw64\\bin;C:\\rtools40\\usr\\bin;C:\\rtools40\\mingw64\\bin;C:\\rtools40\\usr\\bin;C:\\Program Files\\R\\R-4.0.2\\bin\\x64;C:\\Program Files\\R\\R-4.0.2\\bin\\x64;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NGX;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR;C:\\Program Files (x86)\\Tobii\\Tobii Pro X3-120\\;C:\\Program Files\\Git\\cmd;C:\\RTools\\RTools40\\usr\\bin;C:\\RTools\\RTools40\\mingw64\\bin;C:\\Users\\a6m1-\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\a6m1-\\AppData\\Roaming\\TinyTeX\\bin\\win32;C:\\Users\\a6m1-\\AppData\\Local\\Programs\\Microsoft VS Code\\bin"

You have this in PATh and if you run pacman -h in poweshell it also fails?

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

2 Likes

@CLRR has notified me via email that the suggested command in powershell works (cant post themself because of post limit hit being a new user).

2 Likes

@rok_cesnovar Thank you for your posting on behalf of me.

@rok_cesnovar and @andrjohns I really appreciate your quick and helpful replies.

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 <![](chrome-extension://ohhcpmplhhiiaoiddkfboafbhiknefdf/TMToolbar/image/tooltip/webicon_green.png)[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!

@rok_cesnovar Thank you for your posting on behalf of me.

@rok_cesnovar and @andrjohns I really appreciate your quick and helpful replies.

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 <![](chrome-extension://ohhcpmplhhiiaoiddkfboafbhiknefdf/TMToolbar/image/tooltip/webicon_green.png)[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!

1 Like

Yes, that is expected as the suggested line

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

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.

1 Like