Reputation: 11120
Selecting Packages->Update packages...
gave:
> 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 version is 3.0.2.
Upvotes: 29
Views: 23043
Reputation: 72984
This works well for me on Linux:
$ sudo Rscript -e "options(repos=list(CRAN='https://cloud.r-project.org')); \
update.packages(ask=FALSE)"
You can even put it in a nice alias
:)
BTW, I think it's the CRAN recommended packages that want sudo
.
> (rccm <- names(which(
+ available.packages(repos=c(CRAN="https://cran.r-project.org"))[
+ ,"Priority"] == "recommended", )
+ ))
[1] "boot" "class" "cluster" "codetools" "foreign"
[6] "KernSmooth" "lattice" "MASS" "Matrix" "mgcv"
[11] "nlme" "nnet" "rpart" "spatial" "survival"
Note, that if you already installed these into a personal library, they won't get updated with this method. To use the system-wide packages you'd need to remove the personal ones when running R without sudo
i.e. remove.packages(rccm)
and then update with sudo
as shown above, if that makes sense.
Upvotes: 0
Reputation: 29
In my case, we had the following errors:
> install.packages("dplyr")Installing package into ‘C:/Users/username/AppData/Local/R/win-library/4.3’
(as ‘lib’ is unspecified)also installing the dependency ‘vctrs’
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/vctrs_0.6.5.zip'Content type 'application/zip' length 1335663 bytes (1.3 MB)downloaded 1.3 MB
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.3/dplyr_1.1.4.zip'Content type 'application/zip' length 1560779 bytes (1.5 MB)downloaded 1.5 MB
package ‘vctrs’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘vctrs’
Warning in install.packages :
problem copying C:\Users\username\AppData\Local\R\win-library\4.3\00LOCK\vctrs\libs\x64\vctrs.dll to C:\Users\username\AppData\Local\R\win-library\4.3\vctrs\libs\x64\vctrs.dll: Permission denied
Warning in install.packages :
restored ‘vctrs’
package ‘dplyr’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘dplyr’
Warning in install.packages :
problem copying C:\Users\username\AppData\Local\R\win-library\4.3\00LOCK\dplyr\libs\x64\dplyr.dll to C:\Users\username\AppData\Local\R\win-library\4.3\dplyr\libs\x64\dplyr.dll: Permission denied
Warning in install.packages :
restored ‘dplyr’
The downloaded binary packages are in
C:\Users\username\AppData\Local\Temp\RtmpKwqJkg\downloaded_packages
The resolution was to close PowerBI, as the .dll's were in use by that app.
Upvotes: 1
Reputation: 4534
In my case, under Ubuntu and after switching to R 4.x, it was because the package (Matrix) was installed with apt.
sudo apt remove r-cran-matrix
allowed to handle it normally in R.
Upvotes: 0
Reputation: 165
On R 4.0.4 (Gallium OS 3.1)
Permissions? 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
.
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
.
I admit I did not quite understand the help in ?update.packages(), but tried the following.
update.packages(oldPkgs = old.packages())
This fixed the problem and the 3 packages updated.
Upvotes: 9
Reputation: 323
In my case worked the following command sequence in the Terminal of 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.
Upvotes: 3
Reputation: 101
I am on Ubuntu and i have the same problem from RStudio. I have tried to solve by sudo R
and update.packages()
. But it did not help.
However sudo rstudio
+ update.packages()
have solved the problem.
Upvotes: 6
Reputation: 1652
I'm on Windows, but using R Studio Server through SSH tunneling (AWS / Ubunutu Linux). 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
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.
Then, when you acess RStudio Server, you'll see System Library packages updated
In summary, even if you use only one high-privilege unix user on a server, there will be two different locations for libraries:
ubuntu(user):/usr/local/lib/R/
system wide: /usr/lib/R/library
Upvotes: 0
Reputation: 11120
nicePack
, included in the base install, is outdated. update.packages()
or via the equivalent GUI menu. Warning: package 'nicePack' in library 'C:/Program Files/R/R-3.*.*/library" will not be updated
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/...". Anyway you realise that R cannot write to C:/Program Files
and so restart it as Administrator and upgrade, but the problem persists!
If you check the personal package directory, where R is able to write, you see that the updated version of nicePack
is there. In Windows the directory is normally ~\R\win-library\x.y
or find it with 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
. 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.
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.
Delete nicePack
package directory in the personal library directory, restart as administrator and update again.
I don't know if there is an actual bug in this behaviour, anyway more informative messages would for sure help the Windows user.
Perhaps the default library should be avoided in Windows, in favour of the personal. Many Windows applications use C:\ProgramData
or ~\AppData\Local
, writeable without special privileges.
Upvotes: 26