8

I have been having some issues accessing an updated version of a package in R.

On running a workflow for data analysis I got this error message:

library(dplyr) Error: package or namespace load failed for ‘dplyr’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): namespace ‘rlang’ 0.2.1 is already loaded, but >= 0.2.2 is required

I therefore tried to update both the "dplyr" and "rlang" packages.

On updating I get the messages:

Installing package into ‘C:/Users/tomsp/OneDrive/Documents/R/win-library/3.5’ (as ‘lib’ is unspecified) --- Please select a CRAN mirror for use in this session --- trying URL 'https://cran.ma.imperial.ac.uk/bin/windows/contrib/3.5/rlang_0.2.2.zip' Content type 'application/zip' length 820944 bytes (801 KB) downloaded 801 KB

package ‘rlang’ successfully unpacked and MD5 sums checked Warning: cannot remove prior installation of package ‘rlang’

The downloaded binary packages are in C:\Users\tomsp\AppData\Local\Temp\RtmpmooXKa\downloaded_packages

However if I check the package using the code below it still has version 0.2.1

packageVersion("rlang") [1] ‘0.2.1’

I checked my library paths and still have not managed to be run the latest version(0.2.2) of the package rlang.

Any advice of what I am doing wrong or how I can solve this?

tom
  • 83
  • 1
  • 1
  • 3

4 Answers4

13

Restart R and run install.packages again. On Windows, you can't update a package that's already loaded, if the package contains compiled C/C++/Fortran code. This includes dplyr and rlang.

To be doubly sure, before you run install.packages, go to your R packages directory (C:/Users/tomsp/OneDrive/Documents/R/win-library/3.5) and delete any zero-length files that are present. These are artifacts of failed install attempts and will break install.packages if present.

Hong Ooi
  • 56,353
  • 13
  • 134
  • 187
  • Yes, it only worked for me, on Windows, when I delete directory in C:/Users/xxx/Documents/R/win-library/4.1/xxxxx/ – Colibri Jun 14 '22 at 03:21
3

For any reason, at least in Windows, some R processes may still be running in background. Close your current R session, kill all processes related to R and try again.

1

If you are using Windows, check if the package you are trying to upgrade is available only as a source file.

If you try to install a package that needs compilation, you need the software Rtools. Download it on cran.r-project.org/bin/windows/Rtools/. Updating Rtools might also resolve your problem. The console message for a particular package is like that:

                 binary source needs_compilation
      backports  1.2.0  1.2.1              TRUE

On Linux you don't need Rtools, but read the console output when you see an error when you try to install or update a package. If some software is missing, the error message on Linux is self-explanatory.

BMLopes
  • 546
  • 6
  • 10
1

Deleted the entire library from R packages directory on my local computer. Installed again after terminating the session. Worked for me.