更新
我在下面发布了一个工作修复程序。它并没有完全解决问题,但它是一个解决方案。我仍然想让它工作,所以如果有人添加更好的解决方案,我会选择它!
我正在尝试在R中设置环境变量以便通过代理进行连接,但我所做的一切似乎都没有用。 (编辑:我已经完成了我在其他类似帖子中建议的所有内容,通常是通过以某种方式设置http_proxy
或变体)
这是我的sessionInfo()
> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.1.0
我试过了:
Sys.setenv(http_proxy="SERVER:PORT")
然而,该变量未设置:
编辑:Martin Morgan指出我需要在getenv
电话中引用。变量已设置。
> Sys.getenv(http_proxy)
[1] ""
> Sys.setenv(http_proxy="SERVER:PORT")
> Sys.getenv(http_proxy)
[1] ""
但是,它似乎能够连接到代理,但无论我做什么,我都会得到以下的一些变体:
> options(internet.info=0)
> source("http://bioconductor.org/biocLite.R")
Error in file(filename, "r", encoding = encoding) :
cannot open the connection
In addition: Warning messages:
1: In file(filename, "r", encoding = encoding) :
connected to 'SERVER' on port PORT.
2: In file(filename, "r", encoding = encoding) :
-> (Proxy) GET http://bioconductor.org/biocLite.R HTTP/1.0
Host: bioconductor.org
Pragma: no-cache
User-Agent: R (3.0.3 x86_64-apple-darwin13.1.0 x86_64 darwin13.1.0)
3: In file(filename, "r", encoding = encoding) : <- HTTP/1.1 404 Not Found
4: In file(filename, "r", encoding = encoding) :
<- Content-Type: text/html
5: In file(filename, "r", encoding = encoding) :
<- Date: Wed, 14 May 2014 18:10:32 GMT
6: In file(filename, "r", encoding = encoding) : <- Connection: close
7: In file(filename, "r", encoding = encoding) : <- Server: mwg-ui
8: In file(filename, "r", encoding = encoding) :
Code 404, content-type 'text/html'
9: In file(filename, "r", encoding = encoding) :
cannot open: HTTP status was '404 Not Found'
您会注意到,在上面列出的情况下,我收到404
错误;但是,我可以(并且确实)在浏览器中访问该文件。我也尝试过运行它:
> source("~/Downloads/biocLite.R")
Warning: unable to access index for repository http://www.bioconductor.org/packages/2.14/bioc/src/contrib
'biocLite.R' failed to install 'BiocInstaller', use
'install.packages("BiocInstaller",
repos="http://www.bioconductor.org/packages/2.14/bioc")'
Warning message:
package ‘BiocInstaller’ is not available (for R version 3.1.0)
> install.packages("BiocInstaller",
+ repos="http://www.bioconductor.org/packages/2.14/bioc")
Warning: unable to access index for repository http://www.bioconductor.org/packages/2.14/bioc/src/contrib
Warning message:
package ‘BiocInstaller’ is not available (for R version 3.1.0)
更新:尝试从命令行通过http://bioconductor.org/biocLite.R
和wget
下载curl
。工作得很好。
更新:我根据不同来源的建议尝试了一些事情。
在.Renviron
文件中的值周围加上单引号,即`http_proxy ='SERVER:PORT'。
这改变了一些事情,但仍然没有成功。另外,我发现网址引号需要加倍。
源( 'http://bioconductor.org/biocLite.R') 文件错误(文件名,“r”,编码=编码): 无法打开连接 源( “http://bioconductor.org/biocLite.R”) 警告:无法访问存储库http://www.bioconductor.org/packages/2.14/bioc/src/contrib的索引 'biocLite.R'未能安装'BiocInstaller',请使用 “install.packages( “BiocInstaller”, 回购= “http://www.bioconductor.org/packages/2.14/bioc”)” 警告信息: 包'BiocInstaller'不可用(对于R版本3.1.0)
使用空的.Renviron文件和新终端,运行R --vanilla
并安装。这是为了确保需要设置代理。确实如此。
源( 'http://bioconductor.org/biocLite.R') 文件错误(文件名,“r”,编码=编码): 无法打开连接 另外:警告信息: 在文件中(文件名,“r”,编码=编码): 无法连接到端口PORT上的'bioconductor.org'。
在Sys.getenv
电话周围使用引号:[有效,但无法解决问题]
Sys.getenv( “HTTP_PROXY”) [1]“http:// SERVER:PORT /”
答案 0 :(得分:1)
感谢@zhanxw的评论,我又看了一下发生了什么,我意识到虽然正在访问代理服务器,但R使用了错误的端口。
原因如下:我在http_proxy
的末尾有一个额外的转发,这(我假设)导致R错误地解析环境变量。
HTTP_PROXY = “HTTP:// [SERVER]:[PORT] /”
一旦我删除了正斜杠,它就可以正常工作。
以下是我发布的原始“解决方案”。
解决方法,但不是完整的解决方案:
options(download.file.method="wget")
这仍然无法解决原始问题:
源( “http://bioconductor.org/biocLite.R”) 文件错误(文件名,“r”,编码=编码): 无法打开连接
但它确实允许一种替代方法:
> install.packages("BiocInstaller", repos="http://bioconductor.org/packages/2.14/bioc")--2014-05-14 16:08:18-- http://bioconductor.org/packages/2.14/bioc/src/contrib/BiocInstaller_1.14.2.tar.gz
Resolving SERVER... IP, IP, IP, ...
Connecting to SERVER|IP|:PORT... connected.
Proxy request sent, awaiting response... 200 OK
Length: 14053 (14K) [application/x-gzip]
Saving to: '/var/folders/p1/5gstd7bn1hb1t8pd6b7bp5n00000gp/T//RtmpFm0GR3/downloaded_packages/BiocInstaller_1.14.2.tar.gz'
100%[=============================================>] 14,053 --.-K/s in 0s