Stat package will not load after installing RTools

Ever since I installed rtools, the stat package will not load. This is only a problem with R Studio; I can use the stat package when I use R directly. Here is the error I get:

Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Program Files/R/R-3.6.1/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.

I have tried reinstalling R and R Studio. I have tried installing an earlier version of R Studio. I have uninstalled rtools. None of this helps. Please help! I miss R Studio!

2 Likes

I can confirm this bug.

R version 4.0.0 (2020-04-24) -- "Arbor Day"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

Error: package or namespace load failed for ‘stats’ in inDL(x, as.logical(local), as.logical(now), ...):
 unable to load shared object 'C:/Program Files/R/R-4.0.0/library/stats/libs/x64/stats.dll':
  LoadLibrary failure:  The specified module could not be found.

Warning message:
package ‘stats’ in options("defaultPackages") was not found 
Error in inDL(x, as.logical(local), as.logical(now), ...) : 
  unable to load shared object 'C:/Program Files/R/R-4.0.0/library/stats/libs/x64/stats.dll':
  LoadLibrary failure:  The specified module could not be found.
2 Likes

I am also facing the same issue. I tried some solutions of setting environment variable but still facing. Please suggest a solution

2 Likes

Did you resolve the problem? I am experiencing the same thing and no matter how many times I reinstall it won't work. It seems I have to abandon the entire laptop.

1 Like

Hi there, did you resolve this? I have the same issue and would like to know a way out! Thanks.

2 Likes

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.

10 Likes

Thank you for your detailed solution. I will give that a try!! Right now I just reinstalled R and reinstalled RStudio (had to install RStudio in a different directory for it to work, probably because of the hidden files you mentioned), and have not reinstalled Rtools. I was afraid tools will mess up my Rstudio again. I will try your solution. Thank you!

Yay! That worked! I missed having access to RStudio.

Thanks! That works for me !

Thanks! This works for me

Hi, I followed the solution you gave but I cannot find the"./Renviron" folder, so I proceeded to do the rest. When I do the rest and follow the instructions, " *writeLines('PATH="C:\rtools40\usr\bin;${PATH}"', con = "~/.Renviron")" runs and after ristarting is just as if i did noting the mesage error is still there and Sys.which("make") just returns "". So I do not know what else to do. Ive tried everything.

"./Reviron" is a hidden file, not a hidden folder

Step 3 didn't work in R or Rstudio. I get the following error message: Error: '\u' used without hex digits in character string starting "'PATH="C:\rtools40\u"

I modified your instruction a little based on the instruction on the website and it seemed to work (added a couple of ). But the Sys.which did not give me the response you suggested and I cannot install packages. Here is what happens:
writeLines('PATH="C:\rtools40\usr\bin;${PATH}"', con = "~/.Renviron")

Sys.which("make")
make
""

Ok, but were would that file be generated? Inside rtools40 file or somewhere else to kmow were to search

I just searched C: for Reviron and found it that way.

By default, ~./Renviron is supposed to be in library document

Are you sure I'm supposed to delete /Renviron? I messed up RStudio already by changing the PATH.

That's what I did and then reinstalled everything. It worked.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.