R-4.0.0 Tidyverse won't load

I have updated, in this order R (R-4.0.3), RStudio (RStudio-1.3.1093) and rtools (rtools40-x86_64). I accepted all defaults and applied NO custom settings during installation of all 3.

Now, tidyverse and readxl libraries won't load. The problem for both libraries appears to be Rcpp.dll

I have read and applied fixes suggested in multiple RStudio Community posts pertinent to this problem but none of them have fixed my specific problem. I've attempted so many fixes that I'm thoroughly confused and completely flummoxed.

So, I'm making what I hope is not a redundant post and I apologize in advance if it is.

Here are the code and resulting error messages immediately after updating R, Rstudio, and rtools.

> library(tidyverse)
Error: package or namespace load failed for ‘tidyverse’ in inDL(x, as.logical(local), as.logical(now), ...):
 unable to load shared object 'X:/Users/XXX/Documents/R/R-4.0.0/library/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.3 
> library(readxl)
Error: package or namespace load failed for ‘readxl’ in inDL(x, as.logical(local), as.logical(now), ...):
 unable to load shared object 'X:/Users/XXX/Documents/R/R-4.0.0/library/Rcpp/libs/x64/Rcpp.dll':
  LoadLibrary failure:  The specified procedure could not be found.

What I have done:

1. I have removed and reinstalled all three packages:

Remove

> remove.packages("tidyverse")
Removing package from ‘X:/Users/XXX/Documents/R/R-4.0.0/library’
(as ‘lib’ is unspecified)
> remove.packages("Rcpp")
Removing package from ‘X:/Users/XXX/Documents/R/R-4.0.0/library’
(as ‘lib’ is unspecified)
> remove.packages("readxl")
Removing package from ‘X:/Users/XXX/Documents/R/R-4.0.0/library’
(as ‘lib’ is unspecified)

Reinstall

> install.packages(c("tidyverse", "readxl", "Rcpp"))
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/tidyverse_1.3.0.zip'
Content type 'application/zip' length 439951 bytes (429 KB)
downloaded 429 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/readxl_1.3.1.zip'
Content type 'application/zip' length 1708931 bytes (1.6 MB)
downloaded 1.6 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/Rcpp_1.0.5.zip'
Content type 'application/zip' length 3265724 bytes (3.1 MB)
downloaded 3.1 MB

package ‘tidyverse’ successfully unpacked and MD5 sums checked
package ‘readxl’ successfully unpacked and MD5 sums checked
package ‘Rcpp’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	X:/Users/XXX\AppData\Local\Temp\Rtmp4Ofx1M\downloaded_packages

I have confirmed that the binary packages are present
image

2. Following these steps, when I attempt to run the code I received the same error message:

> library(tidyverse)
Error: package or namespace load failed for ‘tidyverse’ in inDL(x, as.logical(local), as.logical(now), ...):
 unable to load shared object 'X:/Users/XXX/Documents/R/R-4.0.0/library/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.3 

and

> library(readxl)
Error: package or namespace load failed for ‘readxl’ in inDL(x, as.logical(local), as.logical(now), ...):
 unable to load shared object 'X:/Users/XXX/Documents/R/R-4.0.0/library/Rcpp/libs/x64/Rcpp.dll':
  LoadLibrary failure:  The specified procedure could not be found.
In addition: Warning message:
package ‘readxl’ was built under R version 4.0.3 

I confirmed that the shared object 'X:/Users/XXX/Documents/R/R-4.0.0/library/Rcpp/libs/x64/Rcpp.dll' is present in the specified directory:
image

I'm stumped

Does anyone have any suggestions?

Have you confirmed that your PATH variable is set correctly for RTools40? What is the output of running Sys.which("make")?

@andresrcs,

Thanks for your response and help.

The output of Sys.which("make") is "C:\rtools40\usr\bin\make.exe"

I verified the existence of the file in the directory:

image

I believe that I have identified a solution to this problem.

The root problem was that, although I had updated to R-4.0.3, RStudio continued to look in "C:/Users/XXX/Documents/R/R-4.0.0/library" for packages.

I found this Stack Overflow post, https://bit.ly/2HwNR4W, in which Ahmed El-Gabbas posted the following suggestion:

I created a new directory for packages, "C:/Users/XXX/Documents/R/win-library/4.0.3".

I started RStudio as an administrator to edit ".Rprofile".

I added the code suggested by Ahmed and edited to be specific to my machine.

#my custom stuff
set_lib_paths <- function(lib_vec) {
  lib_vec <- normalizePath(lib_vec, mustWork = TRUE)
  shim_fun <- .libPaths
  shim_env <- new.env(parent = environment(shim_fun))
  shim_env$.Library <- character()
  shim_env$.Library.site <- character()
  environment(shim_fun) <- shim_env
  shim_fun(lib_vec)
}
set_lib_paths("C:/Users/XXX/Documents/R/win-library/4.0.3") # where "~/code/library" is your package directory (in my case, "~/code/library" = "C:/Users/XXX/Documents/R/win-library/4.0.3").

I saved .Rprofile and exited Rstudio.

I restarted RStudio in regular mode and checked Tools > Install Packages dialogue for the "Install to" library. It was the newly designated packages library folder:
image

Using the Rstudio Tools > Install Packages dialogue, I installed all of the packages listed in the script plus markdown, Rcpp, devtools, and others (install dependencies was selected).

When that process was finished, I copied all of the packages in the original packages library "C:/Users/XXX/Documents/R/win-library/4.0" to the new packages library "C:\Users\XXX\Documents\R\win-library\4.0.3" and chose the option to NOT replace any files previously existing in new library "C:\Users\XXX\Documents\R\win-library\4.0.3" so that only missing files were added to "C:\Users\XXX\Documents\R\win-library\4.0.3".

I restarted R in regular mode and ran the script. The script ran without problem.

> library(readr)
> library(tidyverse)
> library(readxl)
> library(here)
> library(knitr)
> library(kableExtra)
> library(dplyr)
> library(magrittr)
> 
> # read in test file --------------------------------------------------------------------------------
> test_lien_data <-
+   readxl::read_excel(here::here("input_data", "XXXX.xlsx"))

Thanks to @andresrcs for his response and to Ahmed El-Gabbas for his Slack posting.

Is your package library located on a network drive? Does your user name contain non ASCII characters?

Hi @andresrcs,

I discovered the problem and posted it to this thread; however the post is (hopefully) temporarily hidden while a staff member reviews it - most likely because I included a link to the Stack Overflow post where I found the answer to my problem.

The problem was that the installation of the updated R/Rstudio/rtools looked for packages in a non-existent library directory for R-4.0.3 but continued to install packages into the old R library directory for R-4.0.0.

I got a hint that this directory confusion was the root problem by watching the installation process in the console. Apparently, the new installation didn't create this directory, which is different from all previous installations where the library directory was automatically created and selected as the location where packages were to be installed.

The Stack Overflow post described how to solve this problem by manually creating the directory, starting RStudio in administrator mode, and adding code to .Rprofile. A separate posting described copying some packages from the R-4.0.0 library directory to the R-4.0.3 library directory.

set_lib_paths <- function(lib_vec) {
  lib_vec <- normalizePath(lib_vec, mustWork = TRUE)
  shim_fun <- .libPaths
  shim_env <- new.env(parent = environment(shim_fun))
  shim_env$.Library <- character()
  shim_env$.Library.site <- character()
  environment(shim_fun) <- shim_env
  shim_fun(lib_vec)
}
set_lib_paths("~/code/library") # where "~/code/library" is your package directory

Thanks again for your help solving this problem. Your first suggestion indirectly caused me to watch the installation process which then led to the solution. I appreciate that.

Linda

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.