【问题标题】:R 3.1.0 Trouble installing Bioconductor packageR 3.1.0 安装 Bioconductor 包时遇到问题
【发布时间】:2014-05-14 18:43:45
【问题描述】:

更新

我在下面发布了一个有效的修复程序。它并没有完全解决问题,但它是一种解决方法。我仍然想让它工作,所以如果有人添加更好的解决方案,我会选择它!

问题

我正在尝试在 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

我试过了:

  1. 在 .Renviron 和 .Rprofile 中设置“http_proxy”(包括所有大写字母和 https 变体)
  2. 在终端中设置代理变量。
  3. 通过Sys.setenv(http_proxy="SERVER:PORT")设置代理变量
  4. 以上所有内容都适用于 RStudio 和命令行 R

然而,变量没有设置: 编辑: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) 

更新:尝试从命令行通过wgetcurl 下载http://bioconductor.org/biocLite.R。效果很好。

更新:根据不同来源的建议,我尝试了几件事。

  1. .Renviron 文件中的值周围加上单引号,即 `http_proxy='SERVER:PORT'。 这改变了一些东西,但仍然没有成功。另外,我发现 url 引号需要是双引号。

    来源('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", repos="http://www.bioconductor.org/packages/2.14/bioc")' 警告信息: 包‘BiocInstaller’不可用(适用于 R 版本 3.1.0)

  2. 使用空的 .Renviron 文件和新终端,运行 R --vanilla 并安装。这是为了确保需要设置代理。确实如此。

    来源('http://bioconductor.org/biocLite.R') 文件中的错误(文件名,“r”,编码 = 编码): 无法打开连接 另外:警告信息: 在文件(文件名,“r”,编码=编码): 无法连接到端口 PORT 上的“bioconductor.org”。

  3. Sys.getenv 调用周围使用引号:[有效,但不能解决问题]

    Sys.getenv("http_proxy") [1]“http://服务器:端口/”

【问题讨论】:

  • 标题是什么?你有 v3.1.0 而不是 3.03
  • 啊...谢谢。我从 3.03 开始​​,然后在尝试弄清楚时进行了更新。无论哪种方式,结果都相同。
  • 引用Sys.getenv("http_proxy") 的参数,虽然我看不出这对你的问题有什么帮助。
  • 它确实修复了getenv 调用。谢谢!

标签: r macos proxy bioconductor


【解决方案1】:

感谢@zhanxw 的评论,我又看了一下是怎么回事,我意识到虽然正在访问代理服务器,但 R 使用了错误的端口。

原因如下:我的http_proxy 末尾有一个额外的正斜杠,这(我假设)导致 R 错误地解析环境变量。 http_proxy="http://[服务器]:[端口]/" 一旦我删除了尾部的正斜杠,它就可以正常工作了。

以下是我发布的原始“解决方案”。


一种解决方法,但不是完整的解决方案:

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    

【讨论】:

  • 我认为 source() 与 download.file.method 选项无关,所以它可能不起作用,但是,download.file() 尊重它,所以你可以这样做:下载.file("http://bioconductor.org/biocLite.R", "biocLite.R");来源(“biocLite.R”)
  • 你对'source()'是正确的。不幸的是,如果我没记错的话,下载文件仍然无法正常工作,因为后续的“source()”仍然试图通过防火墙并失败。
  • @muppetjones 错误信息是什么?我现在正在使用 UTSW VPN,我可以毫无问题地运行 source("http://bioconductor.org/biocLite.R")。 (R-3.1.0,设置了 proxy_http 环境变量。)
猜你喜欢
  • 2021-04-11
  • 2018-04-19
  • 2019-03-01
  • 1970-01-01
  • 2022-08-24
  • 1970-01-01
  • 2015-06-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多