Unable to load shared object on startup in RStudio only - r

I'm not sure what I did, and my IS team is stumped. I updated R from 3.5.2 to 3.6.0 and R throws this error when opened in RStudio There is no problem when running R in the gui.
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-3.6.0/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.
I can navigate to the stats.dll file and the location matches my .libPaths():
"C:/Program Files/R/R-3.6.0/library"
I have uninstalled and reinstalled both R and RStudio (1.2.1335). I have also restarted my computer. Any help or even temporary solutions would be appreciated.

I found the answer on RStudio Community: I had a typo in one of the variables used in Sys.getenv("PATH")
https://community.rstudio.com/t/unable-to-load-shared-object-on-startup-in-rstudio-only/33107

Related

stats package not found in R

I'm really having problems with RStudio.
It had been working fine a few days ago. Then it said I needed the newest version of RTools. I tried to install it but don't think it was successful. However now I can't load anything in R.
I am greeted with the following message when launching RStudio:
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-3.6.3/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.
During startup - 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-3.6.3/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.
I have looked up solutions to this problem and people say to delete /Renviron but I don't know will that mess things up even more.
Here are a few results of things I type into R:
> Sys.getenv("PATH")
[1] "C:\rtools40"
> Sys.which("stats.dll")
stats.dll
""
> Sys.which("make")
make
""
I really don't understand what has gone wrong. Can anyone help?
You accidentally overwrote the PATH envvar. Your line in .Renviron must be: PATH="C:/rtools40/usr/bin;${PATH}" (mind the " and the {}), otherwise you'll lose the R installation path and R will not be able to load the shared library.

Getting error while installing other packages in R after installing Rtool40 packages

I am facing problem installing any/other packages after I installed the package "Rtools40" in R version 4.0.2. 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 deleting the hidden file of Rtools40 called "./Renviron" still it didn't work for me. Even reinstalled the whole package Rtools40 in my device but I am still getting same error while installing any other R packages like DESeq2.
Please help me to deal with this error.
Thank you for your time.

After installing Rstudio and launching it, I get an rsession.exe system error saying "Rlapack.dll is missing from your computer"

I've just installed R x64 4.0.0 to my computer and have been trying to install RStudio.
When launching R by itself, I'm able to install packages and execute code no problem. However, when I open RStudio I get a system error saying that Rlapack.dll is missing from my computer and am prompted to reinstall the program which I have done several times to no avail. I have also tried reinstalling RStudio several times.
The following errors appear on the RStudio console after "oking" the system error popup:
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.
During startup - 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.
I have also searched for the supposed missing dll in the R installation and found it in this location "C:\Program Files\R\R-4.0.0\bin\x64"
I am unable to run scripts through the RStudio IDE - does anyone know how to fix this dll issue and get RStudio working?
After scouring the internet and spending the best part of a day trying to get to the bottom of this, I have found something that seems to work..
Copy Rlapack.dll from
C:\Program Files\R\R-4.0.0\bin\x64
and paste it into the following locations:
C:\Program Files\R\R-4.0.0\library\stats\libs\x64
C:\Program Files\R\R-4.0.0\library\Matrix\libs\x64

R error that prevents me from executing library(tidyverse) and library(here)

So I installed the 'tidyverse' and 'here' packages from the Install Packages subheader under Tools, and when I try to run the following:
library(tidyverse)
library(here)
I receive an error stating:
Error: package or namespace load failed for ‘tidyverse’ in inDL(x, as.logical(local), as.logical(now), ...):
unable to load shared object 'C:/Users/resha/OneDrive/Documents/R/win-library/4.0/Rcpp/libs/x64/Rcpp.dll':
LoadLibrary failure: The specified procedure could not be found.
In addition: Warning message:
package ‘tidyverse’ was built under R version 4.0.2
Note that my working directory here is "C:/Users/resha/OneDrive/Desktop/STA238 R Documents/Tutorial 0 Files" which is different from 'C:/Users/resha/OneDrive/Documents/R/win-library/4.0/Rcpp/libs/x64/Rcpp.dll' that appears in the error message. Any help please?
It seems there are two steps:
You need to rebuilt your packages under your current R version (your warning message says "package ‘tidyverse’ was built under R version 4.0.2", so you have probably upgraded or downgraded R or used R on another PC with the same shared library on OneDrive?). So please run in your R console:
update.packages(checkBuilt = TRUE, ask = FALSE)
You have your R library on a shared drive on your OneDrive, not your local PC, so:
make sure you have network connection
or make that folder accessible while offline (in your File Explorer right-click on C:/Users/resha/OneDrive/Documents/R/ folder and select "Always keep on this device").

Base packages unavailable after updating R

I've first updated R (from 3.6.3 to 4.0) and afterwards RStudio (from 1.2.5033 to the most recent 1.2.5042) on Windows 10. Because I kept receiving the error messages below, I downgraded to R 3.6.3 and Rstudio 1.1.463. However, the errors persist. When opening RStudio I receive the following:
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-3.6.3/library/stats/libs/x64/stats.dll':
LoadLibrary failure:....
During startup - 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-3.6.3/library/stats/libs/x64/stats.dll':
LoadLibrary failure:...
stats.dll is in the above mentioned location.
Interestingly, I can use functions from the stats package in R.exe suggesting that RStudio causes the errors.
Similarly, I can't print a sessionInfo():
Error in La_library() : LAPACK routines cannot be loaded
In addition: Warning message:
In La_library() :
unable to load shared object 'C:/PROGRA~1/R/R-36~1.3/modules/x64/lapack.dll':
LoadLibrary failure:...
...even though lapack.dll is in the correct place.
It looks as there is confusion between folders of the old (3.6.3) and the new (4.0) version of R, see also this answer.
Suggestion: uninstall both versions of R and install R 4.0 from scratch into a new folder.

Resources