You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法更新R语言包:更新tidyr后引发权限及版本兼容问题

R包更新权限异常问题

问题背景

尝试更新tidyr包后,出现所有R包无法更新的情况,常规解决方案均无效。

已尝试操作

  • 重启电脑及R会话
  • 安装最新版Rtools
  • 更新devtools包
  • 执行update.packages(ask = FALSE)批量更新包
  • 单独尝试重装cli包
  • 使用pacman::p_unlock()清理00LOCK锁定文件

核心报错信息

1. 安装GitHub版tidyr时的依赖报错

> .libPaths()
[1] "C:/Users/first_name.last_name/AppData/Local/R/win-library/4.2"
[2] "C:/Program Files/R/R-4.2.0/library" 

install.packages("devtools")

Installing package into ‘C:/Users/.../AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/devtools_2.4.5.zip'
Content type 'application/zip' length 436566 bytes (426 KB)
downloaded 426 KB

package ‘devtools’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\...\AppData\Local\Temp\1\RtmpszQ0e5\downloaded_packages

devtools::install_github("tidyr")

Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  namespace ‘cli’ 3.3.0 is already loaded, but >= 3.4.0 is required

2. 批量更新包时的权限拒绝报错

> update.packages(ask = FALSE)

Warning: package 'boot' in library 'C:/Program Files/R/R-4.2.0/library' will not be updated
Warning: package 'class' in library 'C:/Program Files/R/R-4.2.0/library' will not be updated
Warning: package 'cluster' in library 'C:/Program Files/R/R-4.2.0/library' will not be updated
Warning: package 'codetools' in library 'C:/Program Files/R/R-4.2.0/library' will not be updated
Warning: package 'foreign' in library 'C:/Program Files/R/R-4.2.0/library' will not be updated
 ...etc.

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/cli_3.6.1.zip'
Content type 'application/zip' length 1332136 bytes (1.3 MB)
downloaded 1.3 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/dplyr_1.1.2.zip'
Content type 'application/zip' length 1553403 bytes (1.5 MB)
downloaded 1.5 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/fansi_1.0.4.zip'
Content type 'application/zip' length 312643 bytes (305 KB)
downloaded 305 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/tibble_3.2.1.zip'
Content type 'application/zip' length 690261 bytes (674 KB)
downloaded 674 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/utf8_1.2.3.zip'
Content type 'application/zip' length 149996 bytes (146 KB)
downloaded 146 KB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/vctrs_0.6.2.zip'
Content type 'application/zip' length 1335280 bytes (1.3 MB)
downloaded 1.3 MB

package ‘cli’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘cli’
Warning: restored ‘cli’
package ‘dplyr’ successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package ‘dplyr’
Warning: restored ‘dplyr’
...etc

The downloaded binary packages are in
    C:\Users\...\AppData\Local\Temp\1\RtmpiAI2dx\downloaded_packages
Warning messages:
1: In file.copy(savedcopy, lib, recursive = TRUE) :
  problem copying C:\Users\...\AppData\Local\R\win-library\4.2\00LOCK\cli\libs\x64\cli.dll to C:\Users\...\AppData\Local\R\win-library\4.2\cli\libs\x64\cli.dll: Permission denied
2: In file.copy(savedcopy, lib, recursive = TRUE) :
  problem copying C:\Users\...\AppData\Local\R\win-library\4.2\00LOCK\dplyr\libs\x64\dplyr.dll to C:\Users\...\AppData\Local\R\win-library\4.2\dplyr\libs\x64\dplyr.dll: Permission denied
3: In file.copy(savedcopy, lib, recursive = TRUE) :
  problem copying C:\Users\...\AppData\Local\R\win-library\4.2\00LOCK\fansi\libs\x64\fansi.dll to C:\Users\...\AppData\Local\R\win-library\4.2\fansi\libs\x64\fansi.dll: Permission denied
4: In file.copy(savedcopy, lib, recursive = TRUE) :
  problem copying C:\Users\...\AppData\Local\R\win-library\4.2\00LOCK\tibble\libs\x64\tibble.dll to C:\Users\...\AppData\Local\R\win-library\4.2\tibble\libs\x64\tibble.dll: Permission denied
5: In file.copy(savedcopy, lib, recursive = TRUE) :
  problem copying C:\Users\...\AppData\Local\R\win-library\4.2\00LOCK\utf8\libs\x64\utf8.dll to C:\Users\...\AppData\Local\R\win-library\4.2\utf8\libs\x64\utf8.dll: Permission denied
6: In file.copy(savedcopy, lib, recursive = TRUE) :
  problem copying C:\Users\...\AppData\Local\R\win-library\4.2\00LOCK\vctrs\libs\x64\vctrs.dll to C:\Users\...\AppData\Local\R\win-library\4.2\vctrs\libs\x64\vctrs.dll: Permission denied

3. 尝试卸载已加载包时的报错

> invisible(lapply(paste0('package:', names(sessionInfo()$otherPkgs)), detach, character.only=TRUE, unload=TRUE))

Error in FUN(X[[i]], ...) : invalid 'name' argument

更新进展:后续操作仍报错

尝试单独重装cli包,重启R会话后依旧失败:

> install.packages("cli")
Error in install.packages : Updating loaded packages

Restarting R session...

> install.packages("cli")
Error in install.packages : Updating loaded packages
> install.packages("cli")
Installing package into ‘C:/Users/.../AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.2/cli_3.6.1.zip'
Content type 'application/zip' length 1332136 bytes (1.3 MB)
downloaded 1.3 MB

package ‘cli’ successfully unpacked and MD5 sums checked
Warning in install.packages :
  cannot remove prior installation of package ‘cli’
Warning in install.packages :
  problem copying C:\Users\...\AppData\Local\R\win-library\4.2\00LOCK\cli\libs\x64\cli.dll to C:\Users\...\AppData\Local\R\win-library\4.2\cli\libs\x64\cli.dll: Permission denied
Warning in install.packages :
  restored ‘cli’

The downloaded binary packages are in
    C:\Users\...\AppData\Local\Temp\1\RtmpSeabMG\downloaded_packages

尝试清理00LOCK文件,未检测到相关文件:

> library(pacman)
Warning message:
package ‘pacman’ was built under R version 4.2.3 
> p_unlock()

No 00LOCK detected in:
 C:/Users/.../AppData/Local/R/win-library/4.2
No 00LOCK detected in:
 C:/Program Files/R/R-4.2.0/library

内容的提问来源于stack exchange,提问作者Nate

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 21:17:05