R - Unable to install R packages - Cannot open the connection - r

Before you mark this as duplicate, I wish to say that I already referred the related post 1,post 2, 3, 4
I am trying to install the dplyr and stringr package but i get the below error
Warning in install.packages :
downloaded length 139264 != reported length 3227450
Warning in install.packages :
error 1 in extracting from zip file
Warning in install.packages :
cannot open compressed file 'dplyr/DESCRIPTION', probable reason 'No such file or directory'
Error in install.packages : cannot open the connection
I tried different installation commands like
install.packages(“dplyr”)
install.packages(“dplyr”, repos="http://cran.us.r-project.org")
install.packages(“dplyr”, repos="http://cran.us.r-project.org",type="win.binary")
> Sys.info()
sysname release version machine
"Windows" "10 x64" "build 17134" "x86-64"
> version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 6.2
year 2019
month 12
day 12
svn rev 77560
language R
version.string R version 3.6.2 (2019-12-12)
nickname Dark and Stormy Night
Till yesterday, I was able to install this package successfully. But today it is throwing this error.
This error happens with other packages like stringr as well. I tried chaging CRAN mirrors as well but still no help
Can help please?

I have downloaded a R package and installed from local files. Next I tried to install a package, with many imports, through Install package(s), I could not install. I closed R and restarted R, now I am able to install packages, with many imports. Rahul, R user.

This error typically happens because R cannot access the default directory for installing the packages. This error is a system-related error. Try this solution. It worked out for me. I changed the default installation directory in the environment variables and it worked smoothly.

Related

GnuTLS Error -50: Cannot install packages from Github in Rstudio?

The following lines prompt an error (which differs from this question):
library(devtools)
install_github("StatsWithR/statsr") # the same for any other open repos
The error is this:
Error: Failed to install 'unknown package' from GitHub:
Error -50 setting GnuTLS cipher list starting with +VERS-TLS1.3
Then I wanted to work around the problem caused by devtools, so I tried githubinstall, but the error became this:
Error in curl::curl_download(input, tmpFile, mode = "wb", quiet = !showProgress) :
Error -50 setting GnuTLS cipher list starting with +VERS-TLS1.3
It seems obvious that the issue is caused by GnuTLS and I found a similar thread: git/jenkins TLS issue, but I cannot find some hints there.
I also tried install_url, install_local, and install_git, but all failed.
Here is the information of the R I recently upgraded from 3.4.4(2018):
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 4
minor 1.2
year 2021
month 11
day 01
svn rev 81115
language R
version.string R version 4.1.2 (2021-11-01)
nickname Bird Hippie
I have been stuck with devtools and install_github. What can I try next?
I installed the r-base and Rstudio using apt install in an existing container, and the default settings(the default r version is 3.4.4) caused the issues I met, then I purged the r environment and created a new one in a new Docker container following this blog: Running RStudio Server with Docker.

R packages failed to install: x86_64-apple-darwin13.4.0-ar: No such file or directory - What is "ar"?

I go this error when installing R packages like RStan (and anything that depends on it such as brms) and Devtools. Since in the message displayed during the installation, everything before this look normal, I think the failure to install can be boiled down to this:
/Users/lambda/anaconda3/bin/x86_64-apple-darwin13.4.0-ar -rs ../lib/libStanHeaders.a cvodes/src/cvodes/cvodes.o cvodes/src/cvodes/cvodes_io.o cvodes/src/cvodes/cvodea.o cvodes/src/cvodes/cvodea_io.o cvodes/src/cvodes/cvodes_direct.o cvodes/src/cvodes/cvodes_band.o cvodes/src/cvodes/cvodes_dense.o cvodes/src/cvodes/cvodes_diag.o cvodes/src/cvodes/cvodes_spils.o cvodes/src/cvodes/cvodes_spbcgs.o cvodes/src/cvodes/cvodes_spgmr.o cvodes/src/cvodes/cvodes_sptfqmr.o cvodes/src/cvodes/cvodes_sparse.o cvodes/src/cvodes/cvodes_bandpre.o cvodes/src/cvodes/cvodes_bbdpre.o cvodes/src/sundials/sundials_band.o cvodes/src/sundials/sundials_direct.o cvodes/src/sundials/sundials_math.o cvodes/src/sundials/sundials_pcg.o cvodes/src/sundials/sundials_spbcgs.o cvodes/src/sundials/sundials_spgmr.o cvodes/src/sundials/sundials_dense.o cvodes/src/sundials/sundials_iterative.o cvodes/src/sundials/sundials_nvector.o cvodes/src/sundials/sundials_sparse.o cvodes/src/sundials/sundials_spfgmr.o cvodes/src/sundials/sundials_sptfqmr.o cvodes/src/nvec_ser/nvector_serial.o
make: /Users/lambda/anaconda3/bin/x86_64-apple-darwin13.4.0-ar: No such file or directory
make: *** [static] Error 1
ERROR: compilation failed for package ‘StanHeaders’
I got this same error both with Xcode compiler and clang4 compiler; I don't think the problem is with the compiler, but with the thing called ar. BTW, I have installed Rcpp and it works. I have seen others having the same problem when installing RPy2. So what is that ar thing and how to fix it?
R version:
> version
_
platform x86_64-apple-darwin13.4.0
arch x86_64
os darwin13.4.0
system x86_64, darwin13.4.0
status
major 3
minor 4.2
year 2017
month 09
day 28
svn rev 73368
language R
version.string R version 3.4.2 (2017-09-28)
nickname Short Summer
I just faced the same problem and I am using anaconda's Rstudio.
My way to fixed it is to install it in terminal, first to try these two on your terminal.
>conda install -c mittner r-rstan
>conda install -c r r-stanheaders #to install the packages in terminal
although I'm not sure where was wrong but it did work fine on me.
hope it helps.
// In the end it seems that there's something wrong with my Anaconda-Navigator, I reinstalled a RStudio and it goes fine.
I had the same problem with Rstudio from anaconda3. Then I from the anaconda navigator (Environments) I installed the gfortran_osx-64 package.
This got me the x86_64-apple-darwin15.5.0-gfortran binary under /anaconda3/bin.
Making a symbolic link did the trick:
elisa#~>ln -s /anaconda3/bin/x86_64-apple-darwin13.4.0-gfortran /anaconda3/bin/x86_64-apple-darwin1
I already solved this problem. I got this problem when using RStudio inside Anaconda. Later I installed R 3.4.3 and RStudio outside Anaconda and everything went smoothly. It might have been some problem with the Anaconda RStudio.

Is MRAN broken?

I have been trying to install packages from MRAN, specifically bsts amoung others. If I run:
install.packages(c("Boom","BoomSpikeSlab", "bsts"),repos = "https://mran.revolutionanalytics.com/snapshot/2016-01-01/")
I get the following output:
Warning in install.packages :
URL 'https://mran.revolutionanalytics.com/snapshot/2016-01-01/bin/macosx/mavericks/contrib/3.3/PACKAGES.gz': status was '404 Not Found'
Warning in install.packages :
URL 'https://mran.revolutionanalytics.com/snapshot/2016-01-01/bin/macosx/mavericks/contrib/3.3/PACKAGES': status was '404 Not Found'
Warning in install.packages :
unable to access index for repository https://mran.revolutionanalytics.com/snapshot/2016-01-01/bin/macosx/mavericks/contrib/3.3:
cannot download all files
Packages which are only available in source form, and may need compilation of C/C++/Fortran: ‘Boom’ ‘BoomSpikeSlab’ ‘bsts’
Do you want to attempt to install these from sources?
y/n:
I also get the same result when changing the repository location using options(). A simple solution would be simply to install from source as below:
install.packages(c("Boom","BoomSpikeSlab", "bsts"),repos = "https://mran.revolutionanalytics.com/snapshot/2016-01-01/",type = "source")
However what doesn't make sense is that, when you check the repository on your browser, the binaries appear to be available:
https://cran.r-project.org/web/packages/bsts/index.html (CRAN)
https://mran.revolutionanalytics.com/snapshot/2016-01-01/web/packages/bsts/index.html (MRAN)
Additionally I would prefer not to have to compile the source code, especially as R's compiler is out of date...
Previous stack overflow questions have suggested this is because the repository is down, however this doesn't make sense as the binaries can be accessed through the browser. So is there an issue with MRAN, is there an issue with install.packages?
I should note I have tried executing this code in both RStudio and R through the terminal. Additionally, for reference, this is my system details:
platform x86_64-apple-darwin13.4.0
arch x86_64
os darwin13.4.0
system x86_64, darwin13.4.0
status
major 3
minor 3.2
year 2016
month 10
day 31
svn rev 71607
language R
version.string R version 3.3.2 (2016-10-31)
nickname Sincere Pumpkin Patch
Thanks in advance for the help.
I've now solved this problem. When calling from the MRAN repository using install.packages you need to capitalise "MRAN" part of the URL.
So this works:
install.packages("bsts", repos = "https://MRAN.revolutionanalytics.com/snapshot/2016-06-01/")
And this only works from source:
install.packages("bsts", repos = "https://mran.revolutionanalytics.com/snapshot/2016-06-01/")

Installing H2o-3 in R

I use the following code to install h2o-3 in R
# The following two commands remove any previously installed H2O packages for R.
if ("package:h2o" %in% search()) { detach("package:h2o", unload=TRUE) }
if ("h2o" %in% rownames(installed.packages())) { remove.packages("h2o") }
# Next, we download packages that H2O depends on.
pkgs <- c("methods","statmod","stats","graphics","RCurl","jsonlite","tools","utils")
for (pkg in pkgs) {
if (! (pkg %in% rownames(installed.packages()))) { install.packages(pkg) }
}
# Now we download, install and initialize the H2O package for R.
install.packages("h2o", type="source", repos=(c("http://h2o-release.s3.amazonaws.com/h2o/rel-turing/3/R")))
library(h2o)
localH2O = h2o.init(nthreads=-1)
# Finally, let's run a demo to see H2O at work.
demo(h2o.kmeans)
It shows the following error.
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-33~1.1/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.3.1\library" C:\Users\pintoo\AppData\Local\Temp\RtmpUxsC47/downloaded_packages/h2o_3.10.0.3.tar.gz' had status 65535
Warning in install.packages :
installation of package ‘h2o’ had non-zero exit status
Then, as the above code, doesn't install package, and it shows it has been downloaded so i tried installing using the downloaded package using the below code
install.packages("C:/Users/pintoo/AppData/Local/Temp/RtmpUL3Da2/downloaded_packages/h2o_3.10.0.3.tar.gz",
repos = NULL, type = "source", dependencies = T)
It produced the below error
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-33~1.1/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.3.1\library" "C:/Users/pintoo/AppData/Local/Temp/RtmpUL3Da2/downloaded_packages/h2o_3.10.0.3.tar.gz"' had status 65535
Warning in install.packages :
installation of package ‘C:/Users/pintoo/AppData/Local/Temp/RtmpUL3Da2/downloaded_packages/h2o_3.10.0.3.tar.gz’ had non-zero exit status
MY version :
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 3.1
year 2016
month 06
day 21
svn rev 70800
language R
version.string R version 3.3.1 (2016-06-21)
nickname Bug in Your Hair
Can any one help me out.
What is this non-zero exit status.
status 65535 meaning?
Non- zero exit status of package means?
The error message you gave is for the second of your two install lines; you don't say what happened with the first one.
But, my recommended way to install H2O on R:
install.packages("h2o")
Simple! This will get the latest version from CRAN, and automatically find all the dependencies. The downside is you are a version or so behind the latest. But the product is mature (so being a version back is fine) and development is fairly rapid (so being a version back can sometimes even be better)!
Only use the instructions on the H2O site if you have a good reason to need the latest version. (And I still recommend installing the first time from CRAN, as it is harder to get something wrong, so if that doesn't work, maybe H2O is incompatible with your machine or something like that.)
P.S. The 65535 (i.e. -1) error code is probably a Windows one, and from some googling appears to be a generic one meaning something crashed. If you do pursue it, I'd be suspicious about either access permissions to certain directories, or paths with spaces in them. (IIRC, R used to recommend not installing in directories with spaces in them.)

Why can't I install the XML package

Am I making some basic error here?
install.packages("XML")
Warning in install.packages :
package ‘XML’ is not available (for R version 2.13.0)
Installing package(s) into ‘C:/Program Files/R/R-2.13.0/library’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘XML’ is not available (for R version 2.13.0)
It is probably because www.omegahat.org doesn't exist anymore. So,
command install.packages("XML", repos = "http://www.omegahat.org/R")
does not work. Instead use below:
install.packages("XML", repos = "http://www.omegahat.net/R")
There can be two conditions when you see such error:
The package does not exist in the library (you should install it
from it's own library)
The package is not compatible with your R
version (you should change your R version that is compatible, if you
can afford it)
For the first condition, search on internet and read about the package you want to install and check the provider and repository (for this case, XML, it is official R package)
For the second condition, you can find the information in the following link:
http://cran.r-project.org/web/packages/XML/index.html
you can check your R version by typing the following command into your R shell:
version
which will give you all the information, for e.g:
_
platform x86_64-apple-darwin10.8.0
arch x86_64
os darwin10.8.0
system x86_64, darwin10.8.0
status
major 3
minor 0.1
year 2013
month 05
day 16
svn rev 62743
language R
version.string R version 3.0.1 (2013-05-16)
nickname Good Sport
First update the R-core:
version
install.package('installr')
library(installr)
updateR()
Then install the XML module:
install.packages("XML")
What worked for me is downloading the old release of the XML package and installing from the package archive
install.packages("~/R/win-library/3.6/XML_3.99-0.3.zip", repos = NULL, type = "win.binary").

Resources