Help with accessing and updating packages: installation of package had non-zero exit status error

Hello,

I run Rstudio on Windows 10 I was recently copying my files from my Onedrive folder to my local C drive. During this process, Rstudio lost the ability to update or install packages, throwing an error for each attempt:

installation of package ‘tidyverse’ had non-zero exit status

I just reinstalled R and Rstudio to my local storage, confirmed my .libpaths() destination was to the parent folder of all the R libraries, and set the "R_LIBS_USER" environment variable to the same place as .libpaths().

What else can I toubleshoot with to find out the problem?

Attached is a screenshot of a "install.packages("tidyverse")" result

Maybe you used this library for an older version of R and now you are trying to use it for a newer version of R?

In general that does not work, and you need to reinstall all packages if you upgrade to a new minor or major R release. E.g. when updating from R 4.0.x to R 4.1.x, etc.

Thank you for your response. To reinstall all packages, do I just need to create a new empty folder and point my .libpaths() and R_LIBS_USER address to the new location?

R_LIBS_USER is already set in R, I suggest you create your library there, and then it will be used automatically, and R will also make sure not to use this library when you update R.

I.e. run this and the restart R once:

dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE, showWarnings = FALSE)

Using the dir.create() with the existing R_LIBS_USER variable did not change anything after restart. Retrying that method with showWarnings = TRUE said that the directory already exists. Running Rstudio as admin did not change the result either.

Afterwards, I used the dir.create() to manually make a new folder at the same destination as the previous but that had no difference either.

Would editing the .Library file potentially help with this problem? I'm running R version 4.0.2 and my .Library path returns "C:/PROGRA~1/R/R-40~1.2/library".

So what is the output of running the following?

Sys.getenv("R_LIBS_USER")
.libPaths()

Do you customize the library path in your profile? If yes, that is not needed and you can delete that customization.

The result of these commands are:

> Sys.getenv("R_LIBS_USER")
[1] "C:\\Users\\kamry\\Documents\\R\\win-library\\4.0"
> .libPaths()
[1] "C:/Users/kamry/Documents/R/win-library/4.0"
[2] "C:/Program Files/R/R-4.0.2/library"    

I have changed the .libPaths() and R_LIBS_USER environment variables during troubleshooting, but that is all. I'm not sure if changing these affects the R profile settings.

That's great, so the library path is set up correctly to the default user library. You should be able to install packages now. WHat are the problems that you are seeing now?

Its the same error output as originally seen. I copy and pasted the entire output (minus the download status) below:

* installing *source* package 'lifecycle' ...
** package 'lifecycle' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  namespace 'rlang' 1.0.2 is being loaded, but >= 1.1.0 is required
Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'lifecycle'
* removing 'C:/Users/kamry/Documents/R/win-library/4.0/lifecycle'
* restoring previous 'C:/Users/kamry/Documents/R/win-library/4.0/lifecycle'
Warning in install.packages :
  installation of package ‘lifecycle’ had non-zero exit status
* installing *source* package 'gargle' ...
** package 'gargle' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  namespace 'rlang' 1.0.2 is being loaded, but >= 1.1.0 is required
Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'gargle'
* removing 'C:/Users/kamry/Documents/R/win-library/4.0/gargle'
* restoring previous 'C:/Users/kamry/Documents/R/win-library/4.0/gargle'
Warning in install.packages :
  installation of package ‘gargle’ had non-zero exit status
* installing *source* package 'dtplyr' ...
** package 'dtplyr' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  namespace 'rlang' 1.0.2 is being loaded, but >= 1.0.4 is required
Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'dtplyr'
* removing 'C:/Users/kamry/Documents/R/win-library/4.0/dtplyr'
* restoring previous 'C:/Users/kamry/Documents/R/win-library/4.0/dtplyr'
Warning in install.packages :
  installation of package ‘dtplyr’ had non-zero exit status
* installing *source* package 'ggplot2' ...
** package 'ggplot2' successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  namespace 'rlang' 1.0.2 is being loaded, but >= 1.1.0 is required
Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'ggplot2'
* removing 'C:/Users/kamry/Documents/R/win-library/4.0/ggplot2'
* restoring previous 'C:/Users/kamry/Documents/R/win-library/4.0/ggplot2'
Warning in install.packages :
  installation of package ‘ggplot2’ had non-zero exit status
* installing *source* package 'pillar' ...
** package 'pillar' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Warning: replacing previous import 'lifecycle::last_warnings' by 'rlang::last_warnings' when loading 'pillar'
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  namespace 'vctrs' 0.4.1 is being loaded, but >= 0.5.0 is required
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'pillar'
* removing 'C:/Users/kamry/Documents/R/win-library/4.0/pillar'
* restoring previous 'C:/Users/kamry/Documents/R/win-library/4.0/pillar'
Warning in install.packages :
  installation of package ‘pillar’ had non-zero exit status
* installing *source* package 'rvest' ...
** package 'rvest' successfully unpacked and MD5 sums checked
** using staged installation
** R
** demo
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  namespace 'rlang' 1.0.2 is being loaded, but >= 1.1.0 is required
Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'rvest'
* removing 'C:/Users/kamry/Documents/R/win-library/4.0/rvest'
* restoring previous 'C:/Users/kamry/Documents/R/win-library/4.0/rvest'
Warning in install.packages :
  installation of package ‘rvest’ had non-zero exit status
* installing *source* package 'stringr' ...
** package 'stringr' successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  namespace 'lifecycle' 1.0.0 is being loaded, but >= 1.0.3 is required
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'stringr'
* removing 'C:/Users/kamry/Documents/R/win-library/4.0/stringr'
* restoring previous 'C:/Users/kamry/Documents/R/win-library/4.0/stringr'
Warning in install.packages :
  installation of package ‘stringr’ had non-zero exit status
* installing *source* package 'broom' ...
** package 'broom' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  namespace 'lifecycle' 1.0.0 is being loaded, but >= 1.0.1 is required
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'broom'
* removing 'C:/Users/kamry/Documents/R/win-library/4.0/broom'
* restoring previous 'C:/Users/kamry/Documents/R/win-library/4.0/broom'
Warning in install.packages :
  installation of package ‘broom’ had non-zero exit status
* installing *source* package 'dbplyr' ...
** package 'dbplyr' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  namespace 'rlang' 1.0.2 is being loaded, but >= 1.1.1 is required
Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'dbplyr'
* removing 'C:/Users/kamry/Documents/R/win-library/4.0/dbplyr'
* restoring previous 'C:/Users/kamry/Documents/R/win-library/4.0/dbplyr'
Warning in install.packages :
  installation of package ‘dbplyr’ had non-zero exit status
* installing *source* package 'googledrive' ...
** package 'googledrive' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  namespace 'gargle' 1.1.0 is being loaded, but >= 1.5.0 is required
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'googledrive'
* removing 'C:/Users/kamry/Documents/R/win-library/4.0/googledrive'
* restoring previous 'C:/Users/kamry/Documents/R/win-library/4.0/googledrive'
Warning in install.packages :
  installation of package ‘googledrive’ had non-zero exit status
* installing *source* package 'googlesheets4' ...
** package 'googlesheets4' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  namespace 'gargle' 1.1.0 is being loaded, but >= 1.5.0 is required
Calls: <Anonymous> ... namespaceImportFrom -> asNamespace -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'googlesheets4'
* removing 'C:/Users/kamry/Documents/R/win-library/4.0/googlesheets4'
* restoring previous 'C:/Users/kamry/Documents/R/win-library/4.0/googlesheets4'
Warning in install.packages :
  installation of package ‘googlesheets4’ had non-zero exit status
* installing *source* package 'modelr' ...
** package 'modelr' successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  namespace 'rlang' 1.0.2 is being loaded, but >= 1.0.6 is required
Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
Execution halted
ERROR: lazy loading failed for package 'modelr'
* removing 'C:/Users/kamry/Documents/R/win-library/4.0/modelr'
* restoring previous 'C:/Users/kamry/Documents/R/win-library/4.0/modelr'
Warning in install.packages :
  installation of package ‘modelr’ had non-zero exit status
* installing *source* package 'tidyverse' ...
** package 'tidyverse' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'tidyverse'
    finding HTML links ... done
    tidyverse-package                       html  
    tidyverse_conflicts                     html  
    tidyverse_deps                          html  
    tidyverse_logo                          html  
    tidyverse_packages                      html  
    tidyverse_sitrep                        html  
    tidyverse_update                        html  
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
*** arch - i386
Warning: package 'ggplot2' was built under R version 4.0.4
Error: package or namespace load failed for 'tidyverse':
 .onAttach failed in attachNamespace() for 'tidyverse', details:
  call: NULL
  error: package or namespace load failed for 'ggplot2' in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 namespace 'pillar' 1.6.0 is being loaded, but >= 1.6.2 is required
Error: loading failed
Execution halted
*** arch - x64
Warning: package 'ggplot2' was built under R version 4.0.4
Error: package or namespace load failed for 'tidyverse':
 .onAttach failed in attachNamespace() for 'tidyverse', details:
  call: NULL
  error: package or namespace load failed for 'ggplot2' in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 namespace 'pillar' 1.6.0 is being loaded, but >= 1.6.2 is required
Error: loading failed
Execution halted
ERROR: loading failed for 'i386', 'x64'
* removing 'C:/Users/kamry/Documents/R/win-library/4.0/tidyverse'
* restoring previous 'C:/Users/kamry/Documents/R/win-library/4.0/tidyverse'
Warning in install.packages :
  installation of package ‘tidyverse’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\kamry\AppData\Local\Temp\RtmpMnJV5t\downloaded_packages’

Seems like you need to reinstall rlang first to have a newer version.

You could give pak a try, it'll probably handle these issues better:

install.packages("pak")
pak::pkg_install("lifecycle")

Hi @Gabor ,

Thank you very much for the help and information on this problem.

I just wanted to inform you that after much research and confusion, I found the reason for my issues. In this article, user Leogama describes that the Documents folder in the Windows directory is a special location and the system itself processes its permissions differently. Even after validating "Documents" folder permissions and running as admin, nothing changed.

After moving my project files up one directory everything started working like normal!

1 Like

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.