R package updates

tom picture tom · Oct 15, 2018 · Viewed 7.1k times · Source

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?

Answer

Hong Ooi picture Hong Ooi · Oct 15, 2018

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.