R - Unable to install R packages - Cannot open the connection
Asked Answered
S

2

0

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?

Sweatband answered 14/4, 2020 at 4:7 Comment(8)
Have you tried downloading the package source files instead? [dplyr_0.8.5.tar.gz](cran.r-project.org/web/packages/dplyr/index.html )Apotheosize
Are you asking me to download this zip file and load them in my workspace as a local package?Sweatband
But isn't there a way to fix this issue? Meaning by using install.packages()?Sweatband
This is likely caused by something outside of R: your virus checker may be interfering with the download, for example. @SidharthMacherla's suggestion may let you work around that.Baldridge
@Baldridge - But it was working fine yesterday.Sweatband
But the same works in R Gui. Meaning install.packages work in R Gui. But when I use them in RStudio, I get this error. Is it possible that I install packages using R gui and load the libraries in RStudio. Will this setup work?Sweatband
Try this solution. It worked out for me.Khorma
Are you running code with smart quotes around dplyr?Channelize
I
0

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.

Infeudation answered 23/6, 2020 at 0:47 Comment(0)
K
0

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.

Khorma answered 27/10, 2021 at 9:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.