Warning in install.packages: unable to access index for repository - r

After installing R version 4.2.0, I was suddenly unable to install packages from CRAN. This was only true from my office site which has a strong firewall.
Warning message pasted below:
> Warning in install.packages: unable to access index for repository
> http://cran.rstudio.com/src/contrib: cannot open URL
> 'http://cran.rstudio.com/src/contrib/PACKAGES' Installing package into
> ‘C:/Users/l2863/AppData/Local/R/win-library/4.2’ (as ‘lib’ is
> unspecified) Warning in install.packages: unable to access index for
> repository http://cran.rstudio.com/src/contrib: cannot open URL
> 'http://cran.rstudio.com/src/contrib/PACKAGES'
I reviewed the similar questions and did not find any solutions that worked.

Installing CRAN packages was restored by going into the Rstudio global options and setting the Primary CRAN repository to USA (TX 1) [https] - Revolution Analytics, Dallas, TX.
I don't know why this worked, whereas selecting USA (TN) [https] - National Institute for Computational Sciences, Oak Ridge did not work.
My company's cyber security engineer stated that the TX location "seemingly points to one specific location, unlike the others."

I found a solution here , it worked with me using R studio on Windows
Go to Tools -> Global Options -> Packages-> Management Tab-> Uncheck "Use secure download method for HTTP"
However, if you prefer to maintain https connection for installing R packages, please refer to this link for more details
If you have this option enabled and still receive a warning message it’s likely you need to select an alternate CRAN mirror that supports HTTPS. Mirrors currently known to support HTTPS are enumerated below in Secure CRAN Mirrors. It’s also possible that you’ve manually specified a download method or CRAN mirror in your .Rprofile that doesn't support secure downloads

Related

How do I resolve "Warning: unable to access index for repository"?

I cannot install almost all packages such as dplyr too.
It also mentioned that my C drive is not writable. How do I solve this issue?
My codes are as follows.
install.packages("kernlab")
Installing package into ‘C:/Users/EliteBook 8440p/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository https://wbc.upm.edu.my/cran/src/contrib:
cannot open URL 'https://wbc.upm.edu.my/cran/src/contrib/PACKAGES'
Warning: unable to access index for repository https://wbc.upm.edu.my/cran/bin/windows/contrib/4.0:
cannot open URL 'https://wbc.upm.edu.my/cran/bin/windows/contrib/4.0/PACKAGES'
Warning message:
package ‘kernlab’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
It looks like it is not your local drive but rather that you cannot access that CRAN mirror (https://wbc.upm.edu.my/cran/bin/windows/contrib/4.0/PACKAGES) to download the {kernlab} package.
Warning: unable to access index for repository
Try manually specifying the repos argument and using the RStudio mirror:
install.packages('kernlab', dependencies=TRUE, repos='http://cran.rstudio.com/')
There are many mirrors that you can source CRAN packages from. Depending on your IT setup, you may not have permission to access all of them. So, manually specifying the download location is one way, you can also set options(repos='http://cran.rstudio.com/') in your .Rprofile.
Another possible wrinkle if you are using RStudio are the Global Options >> Packages settings defining your primary CRAN repository and whether or not you use HTTPS. I would check all of the above things.

there is no package called 'gridExtra' [duplicate]

This question already has answers here:
How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?
(18 answers)
Closed 6 years ago.
I am unable to install packages through latest version of RStudio and R Version.3.1.1. Kindly help. I got the error as mentioned below:
Example:
Warning in install.packages :
InternetOpenUrl failed: ''
Warning in install.packages :
InternetOpenUrl failed: ''
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/3.1
Installing package into ‘C:/Users/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
InternetOpenUrl failed: ''
Warning in install.packages :
InternetOpenUrl failed: ''
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/3.1
Warning in install.packages :
package ‘reshape’ is not available (for R version 3.1.1)
Not 100% certain that you have the same problem, but I found out the hard way that my job blocks each mirror site option that was offered and I was getting errors like this:
Installing package into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Error in download.file(url, destfile = f, quiet = TRUE) :
unsupported URL scheme
Warning: unable to access index for repository https://rweb.crmda.ku.edu/cran/src/contrib
Warning message:
package ‘ggplot2’ is not available (for R version 3.2.2)
Workaround (I am using CentOS)...
install.packages('package_name', dependencies=TRUE, repos='http://cran.rstudio.com/')
I hope this saves someone hours of frustration.
I think this is the "set it and forget it" solution:
options(repos='http://cran.rstudio.com/')
Note that this isn't https. I was on a Linux machine, ssh'ing in. If I used https, it didn't work.
As #Pascal said, it is likely that you encounter problem with the firewall or/and proxy issue.
As a first step, go through FAQ on the CRAN web page. After that, try to flag R with --internet2.
Sometimes it could be useful to check global options in R studio and uncheck "Use Internet Explorer library/proxy for HTTP".
Tools -> Global Options -> Packages and unchecking the "Use Internet Explorer library/proxy for HTTP" option.
Hope this helps.
Based on answers from the community, there appear to be several ways that might solve this:
From the official FAQ and support forums and this answer, you may have have a firewall or proxy issue that is blocking RStudio from connecting to the internet:
Disable any firewalls
Tools -> Global Options -> Packages and unchecking the "Use Internet Explorer library/proxy for HTTP" option and restart R (#1, #2, #3)
Flag R with --internet2
On CentOS it was suggested to try the following: install.packages('package_name', dependencies=TRUE, repos='http://cran.rstudio.com/')
Several answers suggest using an alternate mirror (#1, #2, #3):
Preferences > General > Default working directory > Browse and switch your mirror from local/global (whichever is unchecked)
On Windows you can start the application with http_proxy=http://host:port/:
"C:\Program Files\RStudio\bin\rstudio.exe" http_proxy=http://host:port/
Shut down and restart. Needed after many of the above operations, and suggested standalone.
My solution that worked was to open R studio options and select global miror (the field was empty before) and the error went away.
Please check the following to be able to install new packages:
1- In Tools -> Global Options -> Packages, uncheck the "Use Internet Explorer library/proxy for HTTP" option,
2- In Tools -> Global Options -> Packages, change the CRAN mirror to "0- Cloud - Rstudio, automatic redirection to servers worldwide"
3- Restart Rstudio.
4- Have fun!
If you are on Windows, try this:
"C:\Program Files\RStudio\bin\rstudio.exe" http_proxy=http://host:port/
Most of the time #cer solution works but if in case its not working then try installing it in base R (NOT in R studio). As R studio runs base R executable in background so new package will be available in R studio as well. [my experience in macOS]
What worked for me:
Preferences-General-Default working directory-Browse Switch from global to local mirror
Working on a Mac. 10.10.3

Problems with installation R packages

I'm a Windows user. A few weeks ago I installed R and Rstudio along with many packages. Today there was a message that new packages were not installed.
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
I reinstalled R but this did not solve the problem.
Warning in install.packages :
InternetOpenUrl failed: 'Can not connect to server'
This is something that pops up in R and RStudio only once in a while. RStudio changes quite a few settings, and the option "repos" is one of them. On Windows, the following is added
EDIT: It's not RStudio adding this extra repository. The repository is kindly provided by Dr. Brian Ripley for packages that for some reason can't be made available on CRAN (license, not building out of the box, requiring additional software, ...). This is called "CRANextra" in the settings:
> getOption("repos")
CRAN CRANextra
"https://cran.rstudio.com/" "http://www.stats.ox.ac.uk/pub/RWin"
attr(,"RStudio")
[1] TRUE
So RStudio tries to access a specific repository when run on Windows, but that repository has had some connection issues in the past; it isn't always reachable, and when it's not, the warnings you report are issued.
You can get this warning to stop by resetting this option:
options(repos = "https://cran.rstudio.com") # or a repo of your choice.
Which allows you to install packages without the warning:
> install.packages("fortunes")
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/fortunes_1.5-4.zip'
Content type 'application/zip' length 202721 bytes (197 KB)
downloaded 197 KB
package ‘fortunes’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Joris\AppData\Local\Temp\Rtmpu0febg\downloaded_packages
Even when this warning is displayed, packages still get installed from the rstudio CRAN mirror. The warning is reported as a bug, and RStudio has promised to tackle it soon.
EDIT: More information on the CRANextra repository in R FAQ (last paragraph):
Some CRAN packages that do not build out of the box on Windows,
require additional software, or are shipping third party libraries for
Windows cannot be made available on CRAN in form of a Windows binary
packages. Nevertheless, some of these packages are available at the
“CRAN extras” repository at https://www.stats.ox.ac.uk/pub/RWin/
kindly provided by Brian D. Ripley. Note that this repository is a
default repository for recent versions of R for Windows.
In the mean while R Studio fixes the bug, a temporal solution for not having to especifie the CRAN repository every time we start an R session, is to edit your "Rprofile.site" file and add this line
options(repos = getOption("repos")["CRAN"])
That way every time an R session is started the CRANextra repository ("http://www.stats.ox.ac.uk/pub/RWin") is removed automatically. Just remember to delete or comment with # this line after the bug is solved.
I was facing similar issue and the fix that worked for me is that, in RStudio I've opened tools -> Global Options -> Packages -> Primary CRAN Repository -> Set Global.
Also make sure you're not using installed.packages this happens to a lot of people because of RStudio typing suggestions.
You need to use install.packages("<package_name>")

R Package installation Issue

I'm not able to install any packages in R. I tried in all versions of R starting from 3.2.2 till 3.2.4(revised), but I get the same error. It seems like a proxy issue to me as I'm connected to my college firewall. I was able to install the packages when I'm connected to my home network. Can you please guide me to resolve this issue.?
Here are the error messages
> chooseCRANmirror()
Error in download.file(url, destfile = f, quiet = TRUE) :
cannot open URL 'https://cran.r-project.org/CRAN_mirrors.csv'
In addition: Warning message:
In download.file(url, destfile = f, quiet = TRUE) :
InternetOpenUrl failed: 'The server name or address could not be resolved'
> install.packages("ggplot2")
Installing package into ‘C:/Users/HP/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository https://cran.rstudio.com/src/contrib
Warning: unable to access index for repository
Warning: unable to access index for repository
Warning: unable to access index for repository
Warning message:
package ‘ggplot2’ is not available (for R version 3.2.2)
This is the same problem I was also facing while installing any packages. The main reason what I think is that your R session can't connect to the files path on Cran server.
What I did was just manually go to the Cran website and download the windows release for that particular package. Now unzip the files and manually paste the folder into your library folder of R.
The library folder path will be something like this:
C:\Program Files\R\R-3.2.3\library
Now go to your R console and load it with library(package name).
You can now use your package.
Simply use HTTP mirror instead of HTTPS ones.
To change mirror go to "Packages menu" -> "Set CRAN mirror" -> "(HTTP mirrors)" -> select any
Thanks for your valuable feedback guys. The solution to this problem drove me crazy. I have set my proxy settings according to my college network in MOZILLA, however, I have not set the same for IE. I guess, R downloads the packages based on IE settings, which was not configured. After setting the proxy to connect to the internet, I was able to download the packages without any issues.
Figured this out after trying all your solutions, but at last it was this silly thing that worked.
Thanks for all your time and suggestions.
you can reset and restore your internet connection (for windows and your default explorer),The problem will be solved.
To fix:
Uncheck the 'use secure download method' checkbox in Rstudio global options.
Restart internet then restart Rstudio
utils:::menuInstallPkgs()
--- Please select a CRAN mirror for use in this session ---
Warning: unable to access index for repository https://ftp.iitm.ac.in/cran/src/contrib:
cannot open URL 'https://ftp.iitm.ac.in/cran/src/contrib/PACKAGES'
Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) :
no packages were specified

RStudio package Installation

I had posted a few days earlier about issues in installing packages in RStudio here - RStudio Package installation error. However, my question was marked as duplicate, assuming that the solution posted in the comments is actually the best solution.
Although I have the exact same problem as already mentioned, that solution posted by Ian doesn't help. In fact I get a new kind of error. Please see below:
Warning in install.packages :
unable to connect to 'cran.rstudio.com' on port 80.
Warning in install.packages :
unable to connect to 'cran.rstudio.com' on port 80.
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/bin/windows/contrib/3.1
Warning in install.packages :
unable to connect to 'www.stats.ox.ac.uk' on port 80.
Warning in install.packages :
unable to connect to 'www.stats.ox.ac.uk' on port 80.
Warning in install.packages :
unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.1
Installing package into ‘C:/Users/avi/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
It looks like a connection issue, rather than an installation issue. If you work in an organisation - such as a university - and are behind their firewall it could, for example, be a proxy issue.
Two workarounds (as I'm not a network specialist):
If you can move your data to a personal computer (i.e. no encryption/data protection issues) try installing R and RStudio on another computer and see if you can install packages (preferably using a different internet connection, e.g. from your home).
You can install packages from source, so you could download the package and install without needing a connection in RStudio. See, for example, this post: How do I install an R package from source?
If these do not help, additional information that would be helpful for others would be a list of the package(S) you're trying to install, where you're trying to connect from and if that has a firewall, and how you're trying to install packages (i.e. what commands are you typing). Additionally, your organisation/institution computer services might be able to help.
Good luck.
I have seen this problem on corporate networks where this access method is blocked. One solution is to try RStudio as it uses a different method to install packages and may work for your case.
Do these steps :
Tools -> Global Options -> Packages and uncheck the "Use Internet Explorer library/proxy for HTTP".
Restart R ,and it should work
I've had a similar error. That's what I did to fix it:
Tried to install RODBC -> install.packages("RODBC")
Got a failed to connect to 'cran.r-project.org' on port 80." error message
Used the setInternet2(TRUE) command to force it to use my Internet Explorer proxy config
You can check if the command has worked by typing setInternet2(NA). If it returns [1] TRUE, it's working
In some cases, that should be enough (just run the install.packages again). For me, it wasn't (my proxy server requires a password)
The error that I got after trying to run the install.packages was 407 Proxy Authentication Required
To get rid of this last error message, I had to manually configure my proxy credentials. For that, you will need to run Sys.setenv( "http_proxy"="http://<username>:<password>#<proxy-host>:<port>" ) a real life code should look like this one Sys.setenv( "http_proxy"="http://user:password#192.127.100.32:80" )
After that, I tried to install my packages again end it worked perfectly.
If you can't make it work even after that, you can still download the package using your browser and install it locally.
install.packages( file.choose(), repos=NULL )
The file.choose() will prompt you for the name of the downloaded package file.
This link helped me A LOT with this soluction.

Resources