Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R connect via proxy in Ubuntu

Tags:

r

proxy

rstudio

I had installed RStudio 0.97.168 on Ubuntu 12.04. When I try to install gstat library I get the below error

install.packages("gstat", dependencies=TRUE)

Warning in install.packages :
  cannot open: HTTP status was '407 Proxy Authentication Required'
Warning in install.packages :
  cannot open: HTTP status was '407 Proxy Authentication Required'
Warning in install.packages :
  unable to access index for repository http://software.rc.fas.harvard.edu/mirrors/R/src/contrib
Warning in install.packages :
  package ‘gstat’ is not available (for R version 2.14.1)

I saw solutions like --intenet and setInternet(TRUE) which are only applicable for Windows OS.

Please provide help on changes I need to make to get behind my university proxy?

like image 274
user1142937 Avatar asked Dec 31 '25 00:12

user1142937


1 Answers

You should be able to use the following in your R session:

Sys.setenv(http_proxy="http://user:[email protected]:8080/")

(Obviously, replace with your username, password, proxy server, and port.)

It's important that this is done before you first try to download anything--in other words, done preferably at the start of an R session. From the help page at ?download.file:

These environment variables must be set before the download code is first used: they cannot be altered later by calling Sys.setenv.

There are ways to make this change "permanent" too, but that might be inconvenient if you are working on a laptop or working with multiple internet connections, some of which requires access via a proxy server, and some which don't.

like image 84
A5C1D2H2I1M1N2O1R2T1 Avatar answered Jan 01 '26 13:01

A5C1D2H2I1M1N2O1R2T1