Can't install packages from source (Windows)

Error Information:

Description of issue - For the last few days I can't install R packages from source nor build my own packages. When I try to build any of my own packages I get a window saying Building R packages requires installation of additional build tools. Do you want to install the additional tools ? If I hit Yes, it installs Rtools 4.0 in C:\RBuildTools\4.0 if it is not already installed in that path. But it doesn't build the package. If I try to build again, it repeats the same message --though now it can't install RTools because it is already installed.

Just one week ago everything worked. The only change I'm aware of is something related to Python --I removed Anaconda and installed Python directly, but I've never done anything related to R with Anaconda, so I can't imagine any relationship it may have.

Steps taken so far - I decided to uninstall R, RStudio and RTools and reinstall everything again. Following the instructions here I installed Rtools in C:\rtools40. Sys.which("make")returns the expected output ("C:\\rtools40\\usr\\bin\\make.exe"). But when I try to build my packages or installing from source, I get the same error:

install.packages("jsonlite", type = "source")
# Warning in install.packages :
#  installation of package ‘jsonlite’ had non-zero exit status

System Information:

  • RStudio Edition: Desktop
  • RStudio Version: 2021.09.0-351 (also tried with 1.4.1717)
  • OS Version: Windows 10
  • R Version: 4.1.1 (I got the issue for the first time with 4.1.0)


  • Your sessionInfo():
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

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

loaded via a namespace (and not attached):
[1] compiler_4.1.1 tools_4.1.1   
  • RStudio application log files:
    2021-10-07T13:49:47.870545Z [rsession-MyUserName] WARNING findProgramOnPath returns wrong result: C:\rtools40\usr\bin\ls.exe != C:/rtools40/usr/bin/ls.exe; LOGGED FROM: class rstudio::core::FilePath __cdecl rstudio::session::module_context::findProgram(const class std::basic_string<char,struct std::char_traits,class std::allocator > &) src/cpp/session/SessionModuleContext.cpp:1206