Error: package or namespace load failed

I know there are already quite a few topics on this but none of the solutions in the other threads seems to do the trick for me. I'm relatively new to R so I would really appreciate some help.
Thanks!

Here is my issue:

I recently updated R to 4.0 for Windows 10 (64 bits) and ever since can't load any packages, no matter which ones I choose.
For every package I try to load I get this error:

Fehler: package or namespace load failed for ‘ggplot2’ in get(Info[i, 1], envir = env):
kann Datei 'C:/Users/Sebastian Höer/Documents/R/win-library/4.0/rlang/R/rlang.rdb' nicht öffnen: No such file or directory

The folder "4.0" in "win-library" does contain the packages I am trying to load but somehow R seems to be looking for rlang.rdb for every package instead?

I was also getting a warning during installing packages:
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/

I'm not sure if the warning is anything to worry about?

I've tried reinstalling R and RStudio but that doesn't do anything.

install rtools and follow the instructions as per the link you attached.
after that try

update.packages(checkBuilt=TRUE, ask=FALSE)

Have you tried reinstalling rlang?

install.packages("rlang")

I already had rtools 4.0 installed and followed the instructions but when I tried installing packages: install.packages("package", "source")

I got these error messages:

  • installing source package 'dplyr' ...
    ** Paket 'dplyr' erfolgreich entpackt und MD5 Summen überprüft
    ** using staged installation
    ** libs

*** arch - i386
"C:/rtools40/mingw32/bin/"g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG -I../inst/include -DRCPP_DEFAULT_INCLUDE_CALL=false -DCOMPILING_DPLYR -DRCPP_USING_UTF8_ERROR_STRING -DRCPP_USE_UNWIND_PROTECT -DBOOST_NO_AUTO_PTR -I'C:/Users/Sebastian Höfer/Documents/R/win-library/4.0/BH/include' -I'C:/Users/Sebastian/Documents/R/win-library/4.0/plogr/include' -I'C:/Users/Sebastian Höfer/Documents/R/win-library/4.0/Rcpp/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o
"C:/rtools40/mingw32/bin/"g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG -I../inst/include -DRCPP_DEFAULT_INCLUDE_CALL=false -DCOMPILING_DPLYR -DRCPP_USING_UTF8_ERROR_STRING -DRCPP_USE_UNWIND_PROTECT -DBOOST_NO_AUTO_PTR -I'C:/Users/Sebastian Höfer/Documents/R/win-library/4.0/BH/include' -I'C:/Users/Sebastian/Documents/R/win-library/4.0/plogr/include' -I'C:/Users/Sebastian Höfer/Documents/R/win-library/4.0/Rcpp/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c address.cpp -o address.o
"C:/rtools40/mingw32/bin/"g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG -I../inst/include -DRCPP_DEFAULT_INCLUDE_CALL=false -DCOMPILING_DPLYR -DRCPP_USING_UTF8_ERROR_STRING -DRCPP_USE_UNWIND_PROTECT -DBOOST_NO_AUTO_PTR -I'C:/Users/Sebastian Höfer/Documents/R/win-library/4.0/BH/include' -I'C:/Users/Sebastian/Documents/R/win-library/4.0/plogr/include' -I'C:/Users/Sebastian/Documents/R/win-library/4.0/Rcpp/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c api.cpp -o api.o
"C:/rtools40/mingw32/bin/"g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG -I../inst/include -DRCPP_DEFAULT_INCLUDE_CALL=false -DCOMPILING_DPLYR -DRCPP_USING_UTF8_ERROR_STRING -DRCPP_USE_UNWIND_PROTECT -DBOOST_NO_AUTO_PTR -I'C:/Users/Sebastian Höfer/Documents/R/win-library/4.0/BH/include' -I'C:/Users/Sebastian/Documents/R/win-library/4.0/plogr/include' -I'C:/Users/Sebastian/Documents/R/win-library/4.0/Rcpp/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c arrange.cpp -o arrange.o
"C:/rtools40/mingw32/bin/"g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-40~1.0/include" -DNDEBUG -I../inst/include -DRCPP_DEFAULT_INCLUDE_CALL=false -DCOMPILING_DPLYR -DRCPP_USING_UTF8_ERROR_STRING -DRCPP_USE_UNWIND_PROTECT -DBOOST_NO_AUTO_PTR -I'C:/Users/Sebastian Höfer/Documents/R/win-library/4.0/BH/include' -I'C:/Users/Sebastian/Documents/R/win-library/4.0/plogr/include' -I'C:/Users/Sebastian/Documents/R/win-library/4.0/Rcpp/include' -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c between.cpp -o between.o

And then any code will just be displayed in the console without execution.

Tried that but even after the successful install, I get the same package or namespace load failed error with every package I try to load, with R still no finding rlang.rdb.

Could it have something to do with the path being corrupted?

Can you post a complete installation error message? The last one you have posted is incomplete and it doesn't show any error.

Hi, I am having a similar problem. I have downloaded R Version 4.0 for Windows 10 (64 bits) as well and I get the Error: package or namespace load failed for ‘tidyverse’ in inDL(x, as.logical(local), as.logical(now), ...):unable to load shared object 'C:/Users/mohanlals/Documents/R/win-library/3.6/haven/libs/x64/haven.dll': LoadLibrary failure: The parameter is incorrect.

Please kindly assist.

whats the difference between the path you saw and the path you think you should see ?

you probably have a slightly different issue, as the path here is 3.6 and not 4.0 as would expect

There aren't any error messages during installation, just the warning to use rtools instead, but packages install fine. Loading the packages on the other hand always results in the same error.

Here is the entire output:

install.packages("ggplot2")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/Users/Sebastian Höfer/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
versuche URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/ggplot2_3.3.0.zip'
Content type 'application/zip' length 4011326 bytes (3.8 MB)
downloaded 3.8 MB

package ‘ggplot2’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\Sebastian Höfer\AppData\Local\Temp\RtmpmYoJ3f\downloaded_packages

library(ggplot2)
Fehler: package or namespace load failed for ‘ggplot2’ in get(Info[i, 1], envir = env):
kann Datei 'C:/Users/Sebastian Höfer/Documents/R/win-library/4.0/rlang/R/rlang.rdb' nicht öffnen: No such file or directory

Although it worked fine in previous R versions, is it possible that the special character in the username is causing the issue?

Yes, it is posible, it is know that R has problems with non-ASCII characters and empty spaces on windows user names, try installing to the system level package library instead.

That did the trick, must've been the non-ASCII character.

I had to run Rstudio as administrator, then change the path where packages are installed into like @andresrcs suggested, using .libPaths("C:/Program Files/R/R-4.0.0/userlib") and voila, I am able to load packages again.

Additionally I followed these steps to change the .libPaths permantly.

Thanks everyone for your help!

I have uninstalled version 3.6 and downloaded version 4.0 however I get the same error.

A box comes up that says Rterm.exe - Bad Image
C:\R\R-4.0.0\library\00LOCK-jsonlite\00new\jsonlite\libs\x64\jsonlite.dll is either not designed to run on Windows or it contains an error. Try installing the program again using the original installation media or contact your system administrator or the software vendor for support. Error status 0x0000045.

This Bad Image message appears anytime I try to download any packages.

Beware, I am an absolute beginner but I have had the same initial problem as you had and also have non-ASCII characters as username. I trie following this thread, but when running .libPaths("C:/Program Files/R/R-4.0.0/userlib") , suddenly I cannot install packages anymore:
Warning in install.packages :
package ‘pylr’ is not available (for R version 4.0.0)
Also, the steps to change the .libPaths permanently didn't work.

Before running .libPaths("C:/Program Files/R/R-4.0.0/userlib"), I couldn't run access the packages through library(), but I could see them in the bottom right corner of RStudio within the packages list.

What to do?

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