If you install rtools following official website instructions, here is my solution.
Step 1: Unhidden files and folders in Windows setting
Step 2: Delete the file named "./Renviron" which is a hidden file
After this, you can use Rstudio as normal but not rtools. If you want to use rtools, please finish the next few steps.
Step3: Suppose you install Rtools 40 in default setting, namely the installation fold is "C:\rtools40". Executive the following in R or Rstudio (try both)
writeLines('PATH="C:\rtools40\usr\bin;${PATH}"', con = "~/.Renviron")
Step4: Now restart R, and verify that make can be found, which should show the path to your Rtools installation.
Sys.which("make")
## "C:\\rtools40\\usr\\bin\\make.exe"
Step5:
If this works, you can try to install an R package from source:
install.packages("jsonlite", type = "source")
I hope this can help.