R 库问题 - 无法删除先前安装的包“rlang”

mon*_*key 5 r

当我尝试运行特定函数时:出现以下错误:

\n
> wrangled_devices <- wrangle_devices(params$filtered_devices)\nError in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : \n  namespace \xe2\x80\x98rlang\xe2\x80\x99 0.4.12 is already loaded, but >= 1.0.1 is required\n
Run Code Online (Sandbox Code Playgroud)\n

所以我想我会按照指示更新软件包。但这不起作用:

\n
install.packages("rlang")\nInstalling package into \xe2\x80\x98C:/Users/thebi/Documents/R/win-library/4.1\xe2\x80\x99\n(as \xe2\x80\x98lib\xe2\x80\x99 is unspecified)\ntrying URL \'https://cran.rstudio.com/bin/windows/contrib/4.1/rlang_1.0.2.zip\'\nContent type \'application/zip\' length 1721024 bytes (1.6 MB)\ndownloaded 1.6 MB\n\npackage \xe2\x80\x98rlang\xe2\x80\x99 successfully unpacked and MD5 sums checked\nWarning in install.packages :\n  cannot remove prior installation of package \xe2\x80\x98rlang\xe2\x80\x99\nWarning in install.packages :\n  problem copying C:\\Users\\thebi\\Documents\\R\\win-library\\4.1\\00LOCK\\rlang\\libs\\x64\\rlang.dll to C:\\Users\\thebi\\Documents\\R\\win-library\\4.1\\rlang\\libs\\x64\\rlang.dll: Permission denied\nWarning in install.packages :\n  restored \xe2\x80\x98rlang\xe2\x80\x99\n\nThe downloaded binary packages are in\n    C:\\Users\\thebi\\AppData\\Local\\Temp\\RtmpO2wx0n\\downloaded_packages\n
Run Code Online (Sandbox Code Playgroud)\n

如果我尝试手动删除 rlang 文件夹,它不会让我说它正在另一个程序中使用,尽管我已经关闭了 R studio。我可以强行说明这一点,但我害怕破坏某些东西。

\n

在此输入图像描述

\n

谁能帮我弄清楚这里发生了什么事。我怀疑一旦我对这个图书馆进行排序,就会有另外 100 个图书馆需要同样的处理。

\n

mon*_*key 6

造成这种行为的原因如下。主要 R 项目在 RStudio 中打开。正是在这种环境中,我遇到了问题。

然而,由于我的 R 代码实际上内置于 docker 映像中,作为更大的 CI/CD 控制项目的一部分,我碰巧在 vscode 中打开了几个 R 和 Rmd 文件。我的 vscode 安装了几个 R 插件(当它识别 R 文件时,它实际上会提示您执行此操作)。

事实证明,vscode 会阻止您在 RStudio 中使用包。有关在另一个程序中打开文件夹或文件的消息必须源于 vscode 在后台打开它们。