简体   繁体   English

某些 R 包不会使用 update.packages() 进行更新

[英]Some R packages do not update with update.packages()

Selecting Packages->Update packages... gave:选择Packages->Update packages...给出:

> update.packages(ask='graphics',checkBuilt=TRUE)
--- Please select a CRAN mirror for use in this session ---
Warning: package 'foreign' in library 'C:/Program Files/R/R-3.0.2/library' will not be updated
Warning: package 'lattice' in library 'C:/Program Files/R/R-3.0.2/library' will not be updated
Warning: package 'Matrix' in library 'C:/Program Files/R/R-3.0.2/library' will not be updated
Warning: package 'mgcv' in library 'C:/Program Files/R/R-3.0.2/library' will not be updated
Warning: package 'nlme' in library 'C:/Program Files/R/R-3.0.2/library' will not be updated
Warning: package 'rpart' in library 'C:/Program Files/R/R-3.0.2/library' will not be updated

I ran the R shortcut in the startup menu "as Administrator" and got the same results.我在“以管理员身份”启动菜单中运行了 R 快捷方式并得到了相同的结果。

R version is 3.0.2. R 版本是 3.0.2。

A general restatement of the question问题的一般重述

  1. In Windows 7/8 the package nicePack , included in the base install, is outdated.在 Windows 7/8 中,包含在基本安装中的包nicePack已过时。
  2. You update it with update.packages() or via the equivalent GUI menu.您可以使用update.packages()或通过等效的 GUI 菜单更新它。
  3. You get:你得到:
    Warning: package 'nicePack' in library 'C:/Program Files/R/R-3.*.*/library" will not be updated

Potential causes潜在原因

R is not very kind with Windows so it just says "will not be updated" and not something like "permission denied to C:/Program Files/R/...". R 对 Windows 不太友好,所以它只是说“不会更新”,而不是“拒绝 C:/Program Files/R/... 的权限”。 Anyway you realise that R cannot write to C:/Program Files and so restart it as Administrator and upgrade, but the problem persists!无论如何,您意识到 R 无法写入C:/Program Files ,因此以管理员身份重新启动并升级,但问题仍然存在!

If you check the personal package directory, where R is able to write, you see that the updated version of nicePack is there.如果您查看 R 能够写入的个人包目录,您会看到nicePack的更新版本在那里。 In Windows the directory is normally ~\\R\\win-library\\xy or find it with Sys.getenv("R_LIBS_USER") .在 Windows 中,目录通常是~\\R\\win-library\\xy或使用Sys.getenv("R_LIBS_USER")找到它。

Probably the first time R, unable to write to R default directory, used the personal directory, so that there are two versions of nicePack .大概是第一次用R,无法写入R默认目录,使用了个人目录,所以nicePack有两个版本。 The second time, despite the admin privileges, R finds the updated package version in the personal directory and it does not update the default directory.第二次,尽管有 admin 权限,R 在个人目录中找到更新的包版本并且它没有更新默认目录。

May be that R says "warning" and not "error", because the package is installed in the personal directory, but an outdated version remains in the default library.可能的是,R表示“警告”,而不是“错误”,因为该软件包安装在个人目录,而是一个过时的版本保留在默认库。

Solution解决方案

Delete nicePack package directory in the personal library directory, restart as administrator and update again.删除个人库目录下的nicePack包目录,以管理员身份重启,再次更新。

Opinions意见

I don't know if there is an actual bug in this behaviour, anyway more informative messages would for sure help the Windows user.我不知道这种行为是否存在实际错误,无论如何,提供更多信息的消息肯定会帮助 Windows 用户。

Perhaps the default library should be avoided in Windows, in favour of the personal.也许在 Windows 中应该避免使用默认库,而应该使用个人库。 Many Windows applications use C:\\ProgramData or ~\\AppData\\Local , writeable without special privileges.许多 Windows 应用程序使用C:\\ProgramData~\\AppData\\Local ,无需特殊权限即可写入。

I am on Ubuntu and i have the same problem from RStudio.我在 Ubuntu 上,我在 RStudio 上遇到了同样的问题。 I have tried to solve by sudo R and update.packages() .我试图通过sudo Rupdate.packages() But it did not help.但它没有帮助。 However sudo rstudio + update.packages() have solved the problem.然而sudo rstudio + update.packages()已经解决了这个问题。

In my case worked the following command sequence in the Terminal of Ubuntu:就我而言,在 Ubuntu 的终端中使用了以下命令序列:

sudo i-
R
update.packages(ask=FALSE)
q(save="no")
logout

That is to say: loging as root -> starting R -> updating packages from root -> out of R -> out of root.也就是说:以root身份登录->启动R->从root更新包->退出R->退出root。

On R 4.0.4 (Gallium OS 3.1)在 R 4.0.4 (Gallium OS 3.1) 上

Permissions?权限? old.packages() ? old.packages() ?

In my case, I noticed 3 packages that would not update had permissions set differently from others in /usr/local/lib/R/library .就我而言,我注意到 3 个不会更新的包的权限设置与/usr/local/lib/R/library其他包不同。

I fixed the permissions, but this did not solve the problem.我修复了权限,但这并没有解决问题。

Then I ran old.packages() and noted the SAME 3 packages were considered old .然后我运行old.packages()并注意到 SAME 3 个包被认为是old

I admit I did not quite understand the help in ?update.packages(), but tried the following.我承认我不太明白 ?update.packages() 中的帮助,但尝试了以下方法。

update.packages(oldPkgs = old.packages())

This fixed the problem and the 3 packages updated.这解决了问题并更新了 3 个软件包。

I'm on Windows, but using R Studio Server through SSH tunneling (AWS / Ubunutu Linux).我在 Windows 上,但通过 SSH 隧道(AWS / Ubunutu Linux)使用 R Studio Server。 I think that sometimes R Studio adds a layer of difficulties instead of getting things easier, this happens with package dependencies across multiple UNIX users我认为有时 R Studio 会增加一层困难而不是让事情变得更容易,这发生在多个 UNIX 用户的包依赖关系中

So, adding this possible scenario that may affect people looking for aforementioned question >>>因此,添加这种可能会影响寻找上述问题的人的可能场景 >>>

You can have a package version on your user and other version on您可以在您的用户和其他版本上有一个包版本

You need to su root and install.update() by SUDO R (same of R.exe on Windows) with a root user.您需要使用 root 用户通过SUDO R (与 Windows 上的 R.exe 相同) su root和 install.update()。

Then, when you acess RStudio Server, you'll see System Library packages updated然后,当您访问 RStudio Server 时,您将看到系统库包已更新

In summary, even if you use only one high-privilege unix user on a server, there will be two different locations for libraries:总之,即使您在服务器上仅使用一个高权限 unix 用户,库也会有两个不同的位置:

ubuntu(user): /usr/local/lib/R/ ubuntu(用户): /usr/local/lib/R/

system wide: /usr/lib/R/library系统范围: /usr/lib/R/library

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM