Error installing r package code tools - r

Im trying to update the codetools package and get the same error is I use update.package() or install.package(), as shown below. Any insight is appreciated:
R> install.packages("codetools", lib = "/usr/lib/R/library")
trying URL 'https://cran.rstudio.com/src/contrib/codetools_0.2-14.tar.gz'
Content type 'application/x-gzip' length 12938 bytes (12 KB)
==================================================
downloaded 12 KB
* installing *source* package ‘codetools’ ...
** package ‘codetools’ successfully unpacked and MD5 sums checked
mv: cannot move ‘/usr/lib/R/library/codetools’ to ‘/usr/lib/R/library/00LOCK-codetools/codetools’: Permission denied
Warning in file.copy(f, instdir, TRUE) : problem copying ./NAMESPACE to /usr/lib/R/library/codetools/NAMESPACE: Permission denied
Warning in file(file, ifelse(append, "a", "w")) : cannot open file '/usr/lib/R/library/codetools/DESCRIPTION': Permission denied
Error in file(file, ifelse(append, "a", "w")) : cannot open the connection
ERROR: installing package DESCRIPTION failed for package ‘codetools’
* removing ‘/usr/lib/R/library/codetools’
Warning in install.packages : installation of package ‘codetools’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpiJWb8L/downloaded_packages’
Updating HTML index of packages in '.Library'
Warning in install.packages : cannot create file '/usr/share/R/doc/html/packages.html', reason 'Permission denied'
Warning in install.packages : cannot update HTML package index

Permission denied sounds like you don't have administrator permission on that system. Try running R as root (or with sudo) and see if it works then.

Related

Install R package 'rgdal' and its external dependencies offline on windows

My work laptop has no internet access and I am trying to download the package rgdal.
I have downloaded rgdal_1.4-8.tar.gz, gdal-3.0.4.tar.gz and proj-6.3.2.tar.gz. I tried intalling them via source separately using:
install.packages('.../...tar.gz', type='source', repos=NULL)
but it did not work. Here are the error messages
ERROR: cannot extract package from 'D:/Users/sn/Documents/R source packages/gdal-3.0.4.tar.gz'
Warning in install.packages :
installation of package ‘D:/Users/sn/Documents/R source packages/gdal-3.0.4.tar.gz’ had non-zero exit status
ERROR: cannot extract package from 'D:/Users/sn/Documents/R source packages/proj-6.3.2.tar.gz'
Warning in install.packages :
installation of package ‘D:/Users/sn/Documents/R source packages/proj-6.3.2.tar.gz’ had non-zero exit status
Error in download.file(sprintf("https://github.com/rwinlib/gdal2/archive/v%s.zip", :
cannot open URL 'https://github.com/rwinlib/gdal2/archive/v2.2.3.zip'
In addition: Warning message:
In download.file(sprintf("https://github.com/rwinlib/gdal2/archive/v%s.zip", :
InternetOpenUrl failed: 'A connection with the server could not be established'
Execution halted
make: *** [Makevars.win:27: winlibs] Error 1
ERROR: compilation failed for package 'rgdal'
* removing 'D:/Users/sn/Documents/R/win-library/3.6/rgdal'
Warning in install.packages :
installation of package ‘D:/Users/sn/Documents/R source packages/rgdal_1.4-8.tar.gz’ had non-zero exit status

Installing a package inside RStudio fails on macOS Catalina

While trying to install a package inside RStudio on macOS Catalatina, it fails with a Permission Denied error:
> install.packages("mlbench")
trying URL 'https://cran.rstudio.com/src/contrib/mlbench_2.1-1.tar.gz'
Content type 'application/x-gzip' length 920768 bytes (899 KB)
==================================================
downloaded 899 KB
* installing *source* package ‘mlbench’ ...
** package ‘mlbench’ successfully unpacked and MD5 sums checked
mv: rename /usr/local/Cellar/r/3.6.1_1/lib/R/library/mlbench to /usr/local/Cellar/r/3.6.1_1/lib/R/library/00LOCK-mlbench/mlbench: Permission denied
ERROR: cannot remove earlier installation, is it in use?
* removing ‘/usr/local/Cellar/r/3.6.1_1/lib/R/library/mlbench’
Warning in install.packages :
installation of package ‘mlbench’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/bc/wsz930gj3gn5zgq4hbm6jkfr0000gn/T/RtmpdvQLox/downloaded_packages’
Updating HTML index of packages in '.Library'
Warning in install.packages :
cannot create file '/usr/local/Cellar/r/3.6.1_1/lib/R/doc/html/packages.html', reason 'Permission denied'
Warning in install.packages :
cannot update HTML package index
As stated here by RStudio Support:
Are you able to install packages in R?
If you're having issues, we recommend trying to install packages in R
(outside of RStudio) and see if you're able to do that. If not, please
check the possible solutions below.
Therefore, one needs to:
switch to Terminal.app,
while inside your Terminal, your R console must be started with the sudo privileges. Otherwise, it will yet again fail with a permission denied error. Hence, inside your Terminal, type sudo R,
and then install whatever package is necessary: e.g. install.packages("mlbench").

error installing package "devtools" in R

> install.packages("devtools")
Installing package into ‘C:/Users/hyunj/OneDrive/문서/R/win-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependency ‘withr’
There is a binary version available but
the source version is later:
binary source needs_compilation
withr 2.1.1 2.1.2 FALSE
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/devtools_1.13.5.zip'
Content type 'application/zip' length 443954 bytes (433 KB)
downloaded 433 KB
package ‘devtools’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\hyunj\AppData\Local\Temp\RtmpayZaSB\downloaded_packages
installing the source package ‘withr’
trying URL 'https://cran.rstudio.com/src/contrib/withr_2.1.2.tar.gz'
Content type 'application/x-gzip' length 53578 bytes (52 KB)
downloaded 52 KB
* installing *source* package 'withr' ...
** package 'withr' successfully unpacked and MD5 sums checked
Warning in file(file, if (append) "a" else "w") :
cannot open file 'C:/Users/hyunj/OneDrive/9.<-/R/win-library/3.4/withr/DESCRIPTION': Invalid argument
Error in file(file, if (append) "a" else "w") :
cannot open the connection
ERROR: installing package DESCRIPTION failed for package 'withr'
* removing 'C:/Users/hyunj/OneDrive/문서/R/win-library/3.4/withr'
In R CMD INSTALL
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-34~1.3/bin/x64/R" CMD INSTALL -l "C:\Users\hyunj\OneDrive\문서\R\win-library\3.4" C:\Users\hyunj\AppData\Local\Temp\RtmpayZaSB/downloaded_packages/withr_2.1.2.tar.gz' had status 1
Warning in install.packages :
installation of package ‘withr’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\hyunj\AppData\Local\Temp\RtmpayZaSB\downloaded_packages’
it looks like you have localization problem. All localization problems are hard to debug. Your problem looks like to be in your path probably
C:/Users/hyunj/OneDrive/문서/R/win-library/3.4
If it would be possible to change the "문서" part for something else it might help.

incomplete downloading error while installing a package in R

i am trying to install lubridate package in r using following syntax
install.packages("lubridate")
but it is throwing a error by saying that it is not able to download package completely
below is the error where you can see that downloaded size is not equal to reported size
Installing package into ‘C:/Users/vikas.mittal/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'http://cran.us.r-project.org/bin/windows/contrib/3.3/lubridate_1.6.0.zip'
Content type 'application/zip' length 654286 bytes (638 KB)
downloaded 248 KB
Warning in install.packages :
downloaded length 253952 != reported length 654286
Warning in install.packages :
error 1 in extracting from zip file
Warning in install.packages :
cannot open compressed file 'lubridate/DESCRIPTION', probable reason 'No such file or directory'
Error in install.packages : cannot open the connection

Rcpp install error using ubuntu 14.04 and R 3.2.3 after removing MRO 3.2.3

I am using ubuntu 14.04. I have a problem installing Rcpp after I installed MRO 3.2.3 only to find out that the RevoMath lib did not install. So I had to remove and reinstall R but did not reinstall RStudio.
I researched what I could and read Dirk E's post on R CMD SHLIB which led me to this answer post listed below.
https://stackoverflow.com/a/14389028/5153539
I tried installing with your code and it looked like it was going to work but eventually got the same error as posted below (although I did not try to install Rcpp from the terminal using this method yet).
Any help would be greatly appreciated.
Error when installing Rcpp in RStudio on ubuntu 14.04:
installing source package ‘Rcpp’ ...
package ‘Rcpp’ successfully unpacked and MD5 sums checked Warning in file.copy(f, instdir, TRUE) : problem copying ./NAMESPACE to /home/briangriner/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/NAMESPACE: Permission denied Warning in file(file, ifelse(append, "a", "w")) :
cannot open file '/home/briangriner/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/DESCRIPTION':
Permission denied Error in file(file, ifelse(append, "a", "w")) : cannot open the connection ERROR: installing package DESCRIPTION failed for package ‘Rcpp’
removing ‘/home/briangriner/R/x86_64-pc-linux-gnu-library/3.2/Rcpp’
I think the error is
problem copying ./NAMESPACE to /home/briangriner/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/NAMESPACE: Permission denied
Check the permissions on that Rcpp directory, or just remove it and reinstall Rcpp. As you're on Ubuntu you can also install the (probably a little older) binary package r-cran-rcpp.

Resources