Unable to install packages in latest version of RStudio and R Version.3.1.1
RR Problem Overview
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)
R Solutions
Solution 1 - R
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.
Solution 2 - R
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.
Solution 3 - R
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.
Solution 4 - R
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/')
- 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.
Solution 5 - R
My solution that worked was to open R studio options and select global miror (the field was empty before) and the error went away.
Solution 6 - R
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!
Solution 7 - R
If you are on Windows, try this:
"C:\Program Files\RStudio\bin\rstudio.exe" http_proxy=http://host:port/
Solution 8 - R
What worked for me:
Preferences-General-Default working directory-Browse Switch from global to local mirror
Working on a Mac. 10.10.3
Solution 9 - R
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]