How to install R packages via proxy [user + password]
I need authentication to use the internet, let's say these are my variables:
- Proxy: 1ncproxy1
- Port: 80
- Loggin: MyLoGiN
- Pass: MyPaSs
How do I install a package in R and its addons? To do this, the following would be done:
install.packages("TSA", dependencies=TRUE)
Without our internet connection?
I've tried this:
Sys.setenv("ftp_proxy" = "1ncproxy1","ftp_proxy_user"="MyLoGiN","ftp_proxy_password"="MyPaSs")#Port = 80
But I am getting:
Warning: unable to access index for repository http://cran.ma.imperial.ac.uk/src/contrib
# or
cannot open: HTTP status was '407 Proxy Authentication Required'
Many thanks,
source to share
You may be on Windows, so I would advise you to check the "R on Windows FAQ" that came with your installation, specifically Question 2.19: Internet download functions are not working . R may need to be restarted with the --internet2
(IIRC) option for the proxy settings to take effect.
I've always found this very cumbersome. An alternative is to set up a proxy to work with a web loader, for example wget
(like a Windows binary) where you set the proxy settings in your home directory. This is all from memory, I think the last time I came across such a proxy was in 2005 was YMMV.
source to share
I tried to install vortex packet and had the same problem - proxy with authorization.
After some experimentation, I found a solution. Maybe my answer will help anyone. On Windows 7:
-
set 1 or more (if needed) env variables http_proxy (https_proxy and ftp_proxy if you need) (unless you inject
t know how - read there http://www.computerhope.com/issues/ch000549.htm ) It
env variables for proxy -
format http_proxy = "http: // Proxyusername: ProxyUserPassw @proxyServName: ProxyPort"
-
Use @ instead of% 40
-
In RStudio window Tools-> Global Options-> Packages check the box "Use Internet Explorer Library / Proxy for HTTP"
source to share
As @juba says, I think you want to install http_proxy. From ?download.file
:
Usernames and passwords can be set to pass the HTTP proxy through the http_proxy_user environment variable in the form user: passwd. Alternatively, http_proxy can be of the form "http: // user: pass@proxy.dom.com : 8080 /"
So try: Sys.setenv(http_proxy="http://MyLoGiN:MyPaSs@1ncproxy1:80")
Remember:
These environment variables must be set before the boot code is first used: they cannot be changed later by calling Sys.setenv.
So you better not call him in .Rprofile
source to share
As Jeff Taylor wrote, R can use a proxy server indirectly. You need to specify the proxy server for the http and https protocols as follows:
$ export http_proxy=http://user:pass@proxy_server:port
$ export https_proxy=http://user:pass@proxy_server:port
$ R
> install.packages("<package_name>")
I just tested this solution and it works like a charm. Jeff's answer was correct, but unfortunately incomplete in most cases as most of the servers are currently accessible via https.
source to share