Unable to load packages - library(dplyr)

Hello,

I have messed up my RStudio settings. I am not sure what I did but I have somehow ruined the PATH to my packages. When I try to simply do library(package), I keep getting an error message. I am running my system on Windows.

library(dplyr)
Error: package or namespace load failed for ‘dplyr’ in inDL(x, as.logical(local), as.logical(now), ...):
unable to load shared object 'C:/Program Files/R/R-3.6.2/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module could not be found.
In addition: Warning message:
package ‘dplyr’ was built under R version 3.6.3

Any help will greatly be appreciated.

You have messed with the stats package and maybe other base R packages so I would suggest completely removing your package library and reinstalling R (you could take this opportunity to update R as well).

Thank you for your help. I completely uninstalled R and R studio. Reinstalled them (version 3.6 and 4) but I am still getting this same error messages. Could you tell me the code to remove my package library? How do I reset the stats path? Sorry, I am just so frustrated right now that I cannot do the most simple commands.

Uninstalling R doesn't remove the package library, you have to manually go to the installation folder (use the Windows file explorer) and delete it.
Although if you have installed a new R version this shouldn't be an issue anymore since each R version has an independent package library on Windows. Do you get any different error messages with the new R version?

These are the error messages I am getting now. I am not even able to get into R studio.

R-trouble2

I have been able to re-establish a connection with R. However, I am still getting a number of errors when trying to load packages.

I am not sure if this is progress, but I am not seeing error messages anymore when I start RStudio.

I'm not sure if this is causing your problem but empty spaces in Windows user names usually cause this kind of issues, I would suggest setting your .libPaths to the system level package library only (i.e. "C:\Program Files\R\R-3.6.3\library").

Does this help at all?

.libPaths()
[1] "C:/Users/Sterling L. Wright/Documents/R/win-library/3.6"
[2] "C:/Program Files/R/R-3.6.3/library"
library(reshape2, lib.loc = "C:/Users/Sterling L. Wright/Documents/R/win-library/3.6/")
Error: package or namespace load failed for ‘reshape2’ in get(Info[i, 1], envir = env):
lazy-load database 'C:/Users/Sterling L. Wright/Documents/R/win-library/3.6/Rcpp/R/Rcpp.rdb' is corrupt
In addition: Warning message:
In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

loaded via a namespace (and not attached):
[1] colorspace_1.4-1 compiler_3.6.3 R6_2.4.1 tools_3.6.3
[5] gtable_0.3.0 grid_3.6.3 lifecycle_0.2.0 munsell_0.5.0
[9] rlang_0.4.7

I also ran this

Sys.getenv() [ grep("LIB|PATH", names(Sys.getenv()))]
HOMEPATH \Users\Sterling L. Wright
PATH C:\rtools40\usr\bin;C:\Program
Files\R\R-3.6.3\bin\x64;C:\ProgramData\Anaconda2;C:\ProgramData\Anaconda2\Library\mingw-w64\bin;C:\ProgramData\Anaconda2\Library\usr\bin;C:\ProgramData\Anaconda2\Library\bin;C:\ProgramData\Anaconda2\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Program
Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files
(x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS
Client;C:\Python27;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program
Files\PuTTY;C:\Program Files (x86)\Intel\Intel(R) Management Engine
Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine
Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management
Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management
Engine Components\IPT;C:\WINDOWS\System32\OpenSSH;C:\Program
Files\MEGA-X;C:\Program Files\Intel\WiFi\bin;C:\Program
Files\Common Files\Intel\WirelessCommon;C:\Program
Files\Git\cmd;C:\rtools40\usr\bin;C:\Users\Sterling L.
Wright\AppData\Local\Programs\Python\Python36\Scripts;C:\Users\Sterling
L. Wright\AppData\Local\Programs\Python\Python36;C:\Users\Sterling
L. Wright\AppData\Local\Microsoft\WindowsApps;C:\Users\Sterling L.
Wright\AppData\Local\atom\bin;C:\Users\Sterling L.
Wright\AppData\Local\Microsoft\WindowsApps;C:\rtools40\usr\bin;
PATH2 C:\Python33
PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
R_LIBS_USER C:/Users/Sterling L. Wright/Documents/R/win-library/3.6
RMARKDOWN_MATHJAX_PATH C:/Program Files/RStudio/resources/mathjax-27
RS_RPOSTBACK_PATH C:/Program Files/RStudio/bin/rpostback
UOIPME_REG_PATH C:\Program Files\Intel Corporation\USB over IP

You haven't followed my advice, try installing into the system-level package library instead of your user level package library.

You can change the default values by setting your R_LIBS_SITE environmental variable on a .Reviron or .Rprofile file

# In .Renviron file you can set it by adding this line
R_LIBS_SITE="C:\\Program Files\\R\\R-3.6.3\\library"

okay how do I find and edit the .Renviron file? I tried using the find command in terminal but it was unable to locate it.
When I tried > Sys.getenv("R_PROFILE_USER")
[
This is what I got.

1] ""
Warning messages:
1: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
2: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
3: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
4: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
5: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
6: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
7: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
8: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
9: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1

I also tried your advice by using the following:
install.packages("qqman", lib = "C:/Program Files/R/R-3.6.3/library")

And I am still getting the In get(Info...R_decompress1 error message. I assume it is saying that it is still unable to find the environment for the packages?

@SterlingWright2016: if you have the {usethis} package installed, you may try usethis::edit_r_profile() .

If not, try this from a helpful Stackoverflow post:

> candidates <- c( Sys.getenv("R_PROFILE"),
+                  file.path(Sys.getenv("R_HOME"), "etc", "Rprofile.site"),
+                  Sys.getenv("R_PROFILE_USER"),
+                  file.path(getwd(), ".Rprofile") )
> Filter(file.exists, candidates)
[1] "C:/Data/R-36~1.0/etc/Rprofile.site"
>

Thank you for your help leungi. Could you help me fix my path?

Sys.getenv()
ALLUSERSPROFILE
C:\ProgramData
APPDATA C:\Users\Sterling L.
Wright\AppData\Roaming
asl.log Destination=file
CLICOLOR_FORCE
1
CommonProgramFiles
C:\Program Files\Common
Files
CommonProgramFiles(x86)
C:\Program Files
(x86)\Common Files
CommonProgramW6432
C:\Program Files\Common
Files
COMPUTERNAME
DESKTOP-I84P3TP
ComSpec C:\WINDOWS\system32\cmd.exe
DISPLAY :0
DriverData C:\Windows\System32\Drivers\DriverData
GFORTRAN_STDERR_UNIT
-1
GFORTRAN_STDOUT_UNIT
-1
HOME C:\Users\Sterling L.
Wright\Documents
HOMEDRIVE C:
HOMEPATH \Users\Sterling L. Wright
LOCALAPPDATA
C:\Users\Sterling L.
Wright\AppData\Local
LOGONSERVER \DESKTOP-I84P3TP
MPLENGINE tkAgg
MSYS2_ENV_CONV_EXCL
R_ARCH
NUMBER_OF_PROCESSORS
4
OneDrive C:\Users\Sterling L.
Wright\OneDrive
OnlineServices
Online Services
OS Windows_NT
PATH C:\Program
Files\R\R-4.0.2\bin\x64;C:\ProgramData\Anaconda2;C:\ProgramData\Anaconda2\Library\mingw-w64\bin;C:\ProgramData\Anaconda2\Library\usr\bin;C:\ProgramData\Anaconda2\Library\bin;C:\ProgramData\Anaconda2\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Program
Files (x86)\Common
Files\Oracle\Java\javapath;C:\Program
Files (x86)\Intel\iCLS
Client;C:\Program
Files\Intel\iCLS
Client;C:\Python27;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program
Files\PuTTY;C:\Program
Files (x86)\Intel\Intel(R)
Management Engine
Components\DAL;C:\Program
Files\Intel\Intel(R)
Management Engine
Components\DAL;C:\Program
Files (x86)\Intel\Intel(R)
Management Engine
Components\IPT;C:\Program
Files\Intel\Intel(R)
Management Engine
Components\IPT;C:\WINDOWS\System32\OpenSSH;C:\Program
Files\MEGA-X;C:\Program
Files\Intel\WiFi\bin;C:\Program
Files\Common
Files\Intel\WirelessCommon;C:\Program
Files\Git\cmd;%RTOOLS40_HOME%\usr\bin;C:\Users\Sterling
L.
Wright\AppData\Local\Programs\Python\Python36\Scripts;C:\Users\Sterling
L.
Wright\AppData\Local\Programs\Python\Python36;C:\Users\Sterling
L.
Wright\AppData\Local\Microsoft\WindowsApps;C:\Users\Sterling
L.
Wright\AppData\Local\atom\bin;C:\Users\Sterling
L.
Wright\AppData\Local\Microsoft\WindowsApps;%RTOOLS40_HOME%\usr\bin;
PATH2 C:\Python33
PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Platform MCD
platformcode
KV
PROCESSOR_ARCHITECTURE
AMD64
PROCESSOR_IDENTIFIER
Intel64 Family 6 Model 78
Stepping 3, GenuineIntel
PROCESSOR_LEVEL
6
PROCESSOR_REVISION
4e03
ProgramData C:\ProgramData
ProgramFiles
C:\Program Files
ProgramFiles(x86)
C:\Program Files (x86)
ProgramW6432
C:\Program Files
PSModulePath
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PUBLIC C:\Users\Public
QT_D3DCREATE_MULTITHREADED
1
R_ARCH /x64
R_COMPILED_BY
gcc 8.3.0
R_DOC_DIR C:/PROGRA~1/R/R-40~1.2/doc
R_HOME C:/PROGRA~1/R/R-40~1.2
R_LIBS_USER C:/Users/Sterling L.
Wright/Documents/R/win-library/4.0
R_USER C:/Users/Sterling L.
Wright/Documents
RegionCode NA
RMARKDOWN_MATHJAX_PATH
C:/Program
Files/RStudio/resources/mathjax-27
RS_LOCAL_PEER
\.\pipe\22635-rsession
RS_RPOSTBACK_PATH
C:/Program
Files/RStudio/bin/rpostback
RS_SHARED_SECRET
63341846741
RSTUDIO 1
RSTUDIO_CONSOLE_COLOR
256
RSTUDIO_CONSOLE_WIDTH
80
RSTUDIO_MSYS_SSH
C:/Program
Files/RStudio/bin/msys-ssh-1000-18
RSTUDIO_PANDOC
C:/Program
Files/RStudio/bin/pandoc
RSTUDIO_PROGRAM_MODE
desktop
RSTUDIO_SESSION_PORT
22635
RSTUDIO_USER_IDENTITY
Sterling L. Wright
RSTUDIO_WINUTILS
C:/Program
Files/RStudio/bin/winutils
SESSIONNAME Console
SystemDrive C:
SystemRoot C:\WINDOWS
TEMP C:\Users\STERLI~1.WRI\AppData\Local\Temp
TERM xterm-256color
TMP C:\Users\STERLI~1.WRI\AppData\Local\Temp
UOIPME_REG_PATH
C:\Program Files\Intel
Corporation\USB over IP
USERDOMAIN DESKTOP-I84P3TP
USERDOMAIN_ROAMINGPROFILE
DESKTOP-I84P3TP
USERNAME Sterling L. Wright
USERPROFILE C:\Users\Sterling L. Wright
windir C:\WINDOWS

@SterlingWright2016

I suggest the following:

  • uninstall R and RStudio
  • remove folders where the 2 programs are installed to
  • remove user and system variables referencing R (e.g., R_HOME, R_USER), and let new install set these again
  • reinstall R, without RStudio; recommend installing it in a path with no spaces
  • launch R.exe and test to see

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