51

When you try to install some package of R from GitHub's repository

install_github('rWBclimate', 'ropensci')

If you have the following error:

Installing github repo(s) rWBclimate/master from ropensci
Downloading rWBclimate.zip from https://github.com/ropensci/rWBclimate/archive/master.zip
Error in function (type, msg, asError = TRUE)  :
Could not resolve host: github.com; Host not found, try again

This error is displayed because R is trying to access on Intenet through a proxy.

Guillermo Santos
  • 1,361
  • 1
  • 11
  • 7
  • 1
    Welcome to StackOverflow! While it is highly encouraged for you to provide solutions you have found for problems you have faced and overcome, we prefer that you use the question box solely for questions. You can always answer your own question using the provided answer boxes. There are some [rules](http://stackoverflow.com/help/self-answer) about answering your own question that you may have to follow. And you never know, someone may surprise you by posting another answer you didn't think of! – Enigmadan Jul 22 '13 at 09:50
  • You should really mark the answer below as accepted... – airstrike Nov 27 '17 at 23:01

2 Answers2

75

SOLUTION

Step 1. Install devtools packages

if (!require("devtools")) install.packages("devtools")
library(devtools)

Step 2. Set configuration for our proxy (Please update your information proxy)

library(httr)
set_config(
  use_proxy(url="18.91.12.23", port=8080, username="user",password="password")
)
install_github('rWBclimate', 'ropensci')
Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
Guillermo Santos
  • 1,361
  • 1
  • 11
  • 7
  • 5
    `set_config` and `use_proxy` are part of the `httr` library, so one must run `require(httr)` beforehand. – dmvianna Aug 21 '13 at 23:17
  • thanks. I added `.First <- function() {set_config(use_proxy(...))}; .First()`, along with package dependencies, to `.Rprofile` so that the proxy server is configured automatically on start-up. – Mullefa Jan 28 '14 at 12:29
  • 9
    How do I view what the proxy is currently set to? – HattrickNZ Feb 04 '15 at 01:21
  • 3
    To see what your proxy is currently set to, either `ping wpad` on the command prompt or open `chrome://net-internals/#proxy` on Google Chrome. The latter is likely an URL to a .wpad file which you can download and read with any text editor. I had to set my username including my domain and auth to NTLM, so the full command was more like: `use_proxy(url="X.X.X.X", port=8080, username="MYDOMAIN\\user", password="hunter2", auth="ntlm")` – airstrike Nov 27 '17 at 21:52
  • after much trial and error I got this to work as follows: with_config(use_proxy(url="bcproxy.:8080", username="", password=getPass(), auth="ntlm"), devtools::install_github('hadley/ggplot2')). This required the getPass package – user1420372 Jan 05 '18 at 05:27
8

If setting proxy configuration does not work (as was the case for me), one can download the package from github to local machine:

enter image description here

Unzip the folder and install it from local machine:

devtools::install("C:/path/to/folder/ggbiplot-master")
USER_1
  • 2,409
  • 1
  • 28
  • 28