unable to install package in R Studio

package-installation

#1

Team

I am unable to install any package from my R Studio. Please find below errors while installing the package.

install.packages("ggplot2")
Warning in install.packages :
 unable to access index for repository https://cran.rstudio.com/src/contrib:
 cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
Installing package into ‘C:/Users/Saravana/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
Warning in install.packages :
 unable to access index for repository https://cran.rstudio.com/src/contrib:
 cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
 package ‘ggplot2’ is not available (for R version 3.5.1)
Warning in install.packages :
 unable to access index for repository https://cran.rstudio.com/bin/windows/contrib/3.5:
 cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/PACKAGES'

kindly help me out.

Thanks in advance


#2

Hi,

See this answer to a similar question (the advice applies for cases where you're getting unable to access index for repository for multiple packages):


#3

Hi
Thanks for your reply.

I was turn off my antivirus and I have followed your instruction but I couldnt proceed further.

PFB.

cannot open URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/PACKAGES'
Warning: unable to access index for repository https://cran.rstudio.com/src/contrib:
  cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
> install.packages("C:/Users/Saravana/Downloads/sparklyr_0.9.1.tar.gz", repos = NULL, type = "source")
Installing package into ‘C:/Users/Saravana/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
ERROR: dependencies 'assertthat', 'base64enc', 'broom', 'config', 'DBI', 'dplyr', 'dbplyr', 'digest', 'httr', 'jsonlite', 'lazyeval', 'openssl', 'r2d3', 'rappdirs', 'rlang', 'rprojroot', 'rstudioapi', 'shiny', 'withr', 'xml2', 'tibble', 'tidyr', 'purrr', 'forge' are not available for package 'sparklyr'
* removing 'C:/Users/Saravana/Documents/R/win-library/3.5/sparklyr'
In R CMD INSTALL
Warning in install.packages :
  installation of package ‘C:/Users/Saravana/Downloads/sparklyr_0.9.1.tar.gz’ had non-zero exit status

please help me out.

Thanks in advance.


#4

Hmm, is it possible you're behind a firewall? Those packages it lists are dependencies for sparklyr, when you run regular install.packages() not from source, you can just put the dependencies = TRUE, but obviously that doesn't work for installing from local.

Can you download the httr package? That might let us explore whether or not you can access the internet from R.


#5

Still I am facing the same issue.

install.packages("httr")
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/src/contrib:
  cannot open destfile 'C:\Users\Saravana\AppData\Local\Temp\Rtmp6JHOS1\file15982ac55444', reason 'No such file or directory'
Error in install.packages : cannot open the connection
> install.packages("C:/Users/Saravana/Downloads/sparklyr_0.9.1.tar.gz", repos = NULL, type = "source")
Installing package into ‘C:/Users/Saravana/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
ERROR: dependencies 'assertthat', 'base64enc', 'broom', 'config', 'DBI', 'dplyr', 'dbplyr', 'digest', 'httr', 'jsonlite', 'lazyeval', 'openssl', 'r2d3', 'rappdirs', 'rlang', 'rprojroot', 'rstudioapi', 'shiny', 'withr', 'xml2', 'tibble', 'tidyr', 'purrr', 'forge' are not available for package 'sparklyr'
* removing 'C:/Users/Saravana/Documents/R/win-library/3.5/sparklyr'
In R CMD INSTALL
Warning in install.packages :
  installation of package ‘C:/Users/Saravana/Downloads/sparklyr_0.9.1.tar.gz’ had non-zero exit status
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
  cannot open compressed file 'C:\Users\Saravana\AppData\Local\Temp\Rtmp6JHOS1/libloc_185_a25398df.rds', probable reason 'No such file or directory'
Warning: unable to access index for repository https://cran.rstudio.com/src/contrib:
  cannot open destfile 'C:\Users\Saravana\AppData\Local\Temp\Rtmp6JHOS1\file159861a811a0', reason 'No such file or directory'
Warning: unable to access index for repository https://cran.rstudio.com/src/contrib:
  cannot open destfile 'C:\Users\Saravana\AppData\Local\Temp\Rtmp6JHOS1\file15981f4558b7', reason 'No such file or directory'
Error in gzfile(file, mode) : cannot open the connection

#6

the same package I can able to run in R console.

PFB for the log.

> install.packages("httr")
Installing package into ‘C:/Users/Saravana/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
also installing the dependencies ‘jsonlite’, ‘mime’, ‘curl’, ‘openssl’, ‘R6’

trying URL 'https://ftp.iitm.ac.in/cran/bin/windows/contrib/3.5/jsonlite_1.5.zip'
Error in download.file(url, destfile, method, mode = "wb", ...) : 
  cannot open URL 'https://ftp.iitm.ac.in/cran/bin/windows/contrib/3.5/jsonlite_1.5.zip'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
  InternetOpenUrl failed: 'A connection with the server could not be established'
Warning in download.packages(pkgs, destdir = tmpd, available = available,  :
  download of package ‘jsonlite’ failed
trying URL 'https://ftp.iitm.ac.in/cran/bin/windows/contrib/3.5/mime_0.6.zip'
Content type 'application/zip' length 47811 bytes (46 KB)
downloaded 46 KB

trying URL 'https://ftp.iitm.ac.in/cran/bin/windows/contrib/3.5/curl_3.2.zip'
Content type 'application/zip' length 2986361 bytes (2.8 MB)
downloaded 2.8 MB

trying URL 'https://ftp.iitm.ac.in/cran/bin/windows/contrib/3.5/openssl_1.0.2.zip'
Error in download.file(url, destfile, method, mode = "wb", ...) : 
  cannot open URL 'https://ftp.iitm.ac.in/cran/bin/windows/contrib/3.5/openssl_1.0.2.zip'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
  InternetOpenUrl failed: 'A connection with the server could not be established'
Warning in download.packages(pkgs, destdir = tmpd, available = available,  :
  download of package ‘openssl’ failed
trying URL 'https://ftp.iitm.ac.in/cran/bin/windows/contrib/3.5/R6_2.3.0.zip'
Content type 'application/zip' length 57250 bytes (55 KB)
downloaded 55 KB

trying URL 'https://ftp.iitm.ac.in/cran/bin/windows/contrib/3.5/httr_1.3.1.zip'
Content type 'application/zip' length 482200 bytes (470 KB)
downloaded 470 KB

package ‘mime’ successfully unpacked and MD5 sums checked
package ‘curl’ successfully unpacked and MD5 sums checked
package ‘R6’ successfully unpacked and MD5 sums checked
package ‘httr’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
        C:\Users\Saravana\AppData\Local\Temp\Rtmpollh6D\downloaded_packages

#7

Oh, that's good! It looks like you're able to connect to a different CRAN mirror. You can change that setting in RStudio, too. I'm not at my computer at the moment, but you should also be able to access the successfully downloaded packages in RStudio, since it's just an IDE on top of R.


#8

Hi Mara

once you back to your computer, can you please help me out. I dont know..what settings needs to done? I tried my level best to changed settings, but still I couldnt resolved the issue.

Thanks in advance.


#9

See the pictorial here:


#10

Hi Mara

I couldnt find the secondary source. Please find the attached screenshot for your reference.

please do the needful.


#11

You mean the link doesn't work? What happens when you click on "Change…"?


#12

no.. I am trying to follow your instructions but i could find any secondary Repo...there only I have to enter the name and url..but I couldnt find anything..

please do the needful.


#13

In that case, just enter the URL of the CRAN mirror that worked:

https://ftp.iitm.ac.in/cran/