Hi, I am trying to use R at work and at home on the same computer. At work, I have a proxy, and at home, I do not. I have, for work, a User environment variable "http_proxy" which I set in the OS (Windows XP Pro). When I am at work, and I try to retrieve data from the web with 'read.csv', things work just fine. I assume it knows how to use the proxy. The trouble is when I am at home and have no proxy, R still tries to use my work proxy. I have tried the following: Sys.setenv("http_proxy"="") Sys.setenv("no_proxy"=TRUE) Sys.setenv("no_proxy"=1) none of which seems to work. Whenever I try to use read.csv, it tells me that it cannot find my work proxy, which I am trying to tell R to ignore. I can solve this problem by removing the http_proxy environment variable binding in the OS when at home, but that is a pain, because then I have to reset it when I go back into work. Is there a way to tell R within a session to ignore the proxy? If so, what am I doing wrong? thanks, matt
Note that Windows XP has 4 types of environment variables and I suspect that the problem stems from not taking that into account: http://www.microsoft.com/technet/scriptcenter/guide/sas_wsh_kmmj.mspx?mfr=true On 5/29/07, matt.pettis at thomson.com <matt.pettis at thomson.com> wrote:> Hi, > > I am trying to use R at work and at home on the same computer. At work, I have a proxy, and at home, I do not. I have, for work, a User environment variable "http_proxy" which I set in the OS (Windows XP Pro). When I am at work, and I try to retrieve data from the web with 'read.csv', things work just fine. I assume it knows how to use the proxy. > > The trouble is when I am at home and have no proxy, R still tries to use my work proxy. I have tried the following: > > Sys.setenv("http_proxy"="") > Sys.setenv("no_proxy"=TRUE) > Sys.setenv("no_proxy"=1) > > none of which seems to work. Whenever I try to use read.csv, it tells me that it cannot find my work proxy, which I am trying to tell R to ignore. > > I can solve this problem by removing the http_proxy environment variable binding in the OS when at home, but that is a pain, because then I have to reset it when I go back into work. > > Is there a way to tell R within a session to ignore the proxy? If so, what am I doing wrong? > > thanks, > matt > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
One other point. If you find you need to set a system or user environment variable then microsoft has a free tool called setx.exe that you can find here: http://support.microsoft.com/kb/927229 You can do this from within R using system(). On 5/30/07, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:> On 5/29/07, matt.pettis at thomson.com <matt.pettis at thomson.com> wrote: > > OK, I think I get that... do you know which namespace the Sys.setenv() function affects? Do you know if there are functions in R that can alter the user/system/process environment variables? > > > > Use the R Sys.getenv() command to get the process environment variables. > To get user and system environment variables, from the Desktop right click on > My Computer and choose Properties. Then choose the Advanced tab > and click on the Environment Variables button near the bottom of the > window that appears. >
There is also a free program setenv.exe which is more powerful than setx.exe. You mentioned that deleting http_proxy from your environment through the OS would fix your problem. setenv.exe can both set and delete environment variables and you can specify user, system, etc. See description and link here: http://www.jsifaq.com/SF/Tips/Tip.aspx?id=4928 Grothendieck <ggrothendieck at gmail.com> wrote:> One other point. If you find you need to set a system or user environment > variable then microsoft has a free tool called setx.exe that you can find here: > > http://support.microsoft.com/kb/927229 > > You can do this from within R using system(). > > On 5/30/07, Gabor Grothendieck <ggrothendieck at gmail.com> wrote: > > On 5/29/07, matt.pettis at thomson.com <matt.pettis at thomson.com> wrote: > > > OK, I think I get that... do you know which namespace the Sys.setenv() function affects? Do you know if there are functions in R that can alter the user/system/process environment variables? > > > > > > > Use the R Sys.getenv() command to get the process environment variables. > > To get user and system environment variables, from the Desktop right click on > > My Computer and choose Properties. Then choose the Advanced tab > > and click on the Environment Variables button near the bottom of the > > window that appears. > > >