rstudio / renv

renv: Project environments for R.
https://rstudio.github.io/renv/
MIT License
1.02k stars 155 forks source link

renv behind a corporate Proxy. Improve documentation? #146

Closed ugzvot closed 5 years ago

ugzvot commented 5 years ago

Like in https://github.com/rstudio/renv/issues/64 we have an awful man in the middle Proxy using Windows logins (SSPI) and the ntlm authentication protocol. A good explanation is found in this stackoverflow answer. To make matter worse, the bundled curl is removed from our windows image.

renv::install() fails:

> renv::install("xtable")
Retrieving 'https://cran.rstudio.com/bin/windows/contrib/3.5/xtable_1.8-4.zip' ...
Warning message:
In (function (url, destfile, method, quiet = FALSE, mode = "w",  :
  URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/xtable_1.8-4.zip': status was 'HTTP response code said error'

I found a simple solution in the end, but it was cumbersome to find all the pieces of information:

• Install curl with renv::equip() • Create following _curlrc in Sys.getenv("HOME") or Sys.getenv("R_USER")

--proxy "your.proxy.dns:port"
--proxy-ntlm
--proxy-user ":"
--insecure

The double quotes are important. : is interpreted as separator. See https://github.com/curl/curl/issues/3738#issuecomment-480379380

> renv::install("xtable")
Retrieving 'https://cran.rstudio.com/bin/windows/contrib/3.5/xtable_1.8-4.zip' ...
    OK [downloaded 688.3 Kb in 1.9 secs]
Installing xtable [1.8-4] from CRAN ...
    OK (installed binary)
* Copying 'xtable' into the cache ... Done!

edit: Added console output for successful install

kevinushey commented 5 years ago

I'm going to consider it a success that renv was able to work in this configuration without any extra changes from me :-)

I've added some documentation to the Getting Started vignette to give some hints as to how to configure renv + curl to use proxy servers, though. Let me know if you think that's sufficient.

ugzvot commented 5 years ago

Seems good. Perhaps change the last paragraph to:

See the curl documentation on [proxies](https://ec.haxx.se/usingcurl-proxies.html) and [config files](https://ec.haxx.se/cmdline-configfile.html) for more details.

And perhaps add the example _curlrc and drop the keywords ntlm and sspi, something along the lines:

This config file works with a common proxy setup in a windows environment (authentication with ntlm and sspi):

```
--proxy "your.proxy.dns:port"
--proxy-ntlm
--proxy-user ":"
--insecure
```

In the best case it works for the user, else he has some keywords to start googling or asking his IT support.

The curl packages has the helper function curl::ie_get_proxy_for_url() to find the proxy address. Don't know if this should be included.

I struggled mostly with the following points:

-Then the _curlrc format first i had proxy-user = : and ran into https://github.com/curl/curl/issues/3738#issuecomment-480379380.

As an after thought: yeah it is definitely a success. And the problems I had, was with the missing curl, the correct curl configuration and missing knowledge about proxy authentication not in renv. renv has even the tools to help me with the missing curl. On the other side, i had a working setup for install.packages() and remotes::install_*.

Yesterday i was just a bit frustrated about how simple the solution is, but i wasted a lot of time to get the configuration right.

kevinushey commented 5 years ago

Thank you for the feedback -- it is hugely appreciated. I've updated the documentation with that example, and also altered how renv looks for _curlrc (since the documentation makes it clear that curl would normally look in %APPDATA% and the other folder as well).