简体   繁体   English

R 3.1.0无法安装Bioconductor软件包

[英]R 3.1.0 Trouble installing Bioconductor package

Update 更新

I posted a working fix below. 我在下面发布了工作修补程序。 It doesn't completely solve the problem, but it is a work around. 它不能完全解决问题,但是可以解决。 I would still like to get it working, so if anyone adds a better solution, I'll select it! 我仍然希望它能正常工作,所以如果有人添加更好的解决方案,我会选择它!

Problem 问题

I am trying to set environment variables in R in order to connect through a proxy, but nothing I do seems to work. 我正在尝试在R中设置环境变量,以便通过代理进行连接,但是我似乎无济于事。 (edit: I have done everything I have found suggested in other similar posts, which is usually via setting http_proxy or variants in some manner) (编辑:我已经完成了在其他类似帖子中发现的所有建议,通常是通过以某种方式设置http_proxy或变体)

Here is my sessionInfo() 这是我的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

I have tried: 我努力了:

  1. setting 'http_proxy' (including all caps and https variations) in .Renviron and .Rprofile 在.Renviron和.Rprofile中设置“ http_proxy”(包括所有大写字母和https变体)
  2. setting the proxy variables in the terminal. 在终端中设置代理变量。
  3. setting the proxy variables via Sys.setenv(http_proxy="SERVER:PORT") 通过Sys.setenv(http_proxy="SERVER:PORT")设置代理变量
  4. all of the above for both RStudio and command line R 以上所有对于RStudio和命令行R

Yet, the variable is not set: Edit: Martin Morgan pointed out that I needed quotations in the getenv call. 但是,该变量尚未设置: 编辑:Martin Morgan指出,在getenv调用中需要引用。 The variable is set. 变量已设置。

> Sys.getenv(http_proxy)
[1] ""
> Sys.setenv(http_proxy="SERVER:PORT")
> Sys.getenv(http_proxy)
[1] ""

Still, it seems to be able to connect to the proxy, but no matter what I do, I get some variation of the following: 尽管如此,它似乎能够连接到代理,但是无论我做什么,我都会得到以下变化:

> 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'

You will notice that in the case listed above, I get a 404 error; 您会注意到,在上述情况下,我收到404错误; however, I can (and did) access the file in browser. 但是,我可以(并且确实)在浏览器中访问文件。 I tried running it as well: 我也尝试运行它:

> 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) 

Update: Tried downloading http://bioconductor.org/biocLite.R via wget and curl from the command line. 更新:尝试通过wgetcurl从命令行下载http://bioconductor.org/biocLite.R Works just fine. 效果很好。

Update: I tried a couple of things after suggestions from different sources. 更新:根据不同来源的建议,我尝试了几件事。

  1. Put single quotes around the values in the .Renviron file, ie, `http_proxy='SERVER:PORT'. .Renviron文件中的值.Renviron单引号,即“ http_proxy ='SERVER:PORT'。 This changed something, but still no success. 这改变了一些东西,但仍然没有成功。 Also, I found out that the url quotes need to be double. 另外,我发现url引号需要加倍。

    source(' http://bioconductor.org/biocLite.R ') Error in file(filename, "r", encoding = encoding) : cannot open the connection source(" http://bioconductor.org/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) source(' 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. With an empty .Renviron file and a fresh terminal, run R --vanilla and install. 使用一个空的.Renviron文件和一个新的终端,运行R --vanilla并安装。 This was intended to ensure that the proxy needed to be set. 目的是确保需要设置代理。 And it does. 确实如此。

    source(' http://bioconductor.org/biocLite.R ') Error in file(filename, "r", encoding = encoding) : cannot open the connection In addition: Warning message: In file(filename, "r", encoding = encoding) : unable to connect to 'bioconductor.org' on port PORT. source(' http://bioconductor.org/biocLite.R ')文件错误(文件名,“ r”,编码=编码):无法打开连接另外:警告消息:在文件(文件名,“ r”,编码=编码):无法在端口PORT上连接到“ bioconductor.org”。

  3. Use quotes around the Sys.getenv call: [worked, but doesn't fix the problem] Sys.getenv调用周围使用引号:[有效,但不能解决问题]

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

Thanks to the comment from @zhanxw, I took another look at what was going on, and I realized that although the proxy server was being accessed, R was using the wrong port. 感谢@zhanxw的评论,我再次查看了正在发生的事情,并且我意识到尽管正在访问代理服务器,但是R使用了错误的端口。

Here's why: I had an extra forwardslash at the end of my http_proxy , which (I'm assuming) caused R to parse the environment variable incorrectly. 原因如下: http_proxy的末尾有一个额外的正http_proxy (我假设),这导致R错误地解析了环境变量。 http_proxy="http://[SERVER]:[PORT]/" Once I removed the trailing forward slash, it works fine. http_proxy =“ http:// [SERVER]:[PORT] /”一旦删除了尾随的前斜杠,它就可以正常工作。

Below is the original "solution" I posted. 以下是我发布的原始“解决方案”。


A workaround, but not a complete solution: 解决方法,但不是完整的解决方案:

options(download.file.method="wget")

This still does not fix the original problem: 这仍然不能解决原始问题:

source(" http://bioconductor.org/biocLite.R ") Error in file(filename, "r", encoding = encoding) : cannot open the connection source(“ http://bioconductor.org/biocLite.R ”)文件错误(文件名“ r”,编码=编码):无法打开连接

But it does allow for an alternative method to work: 但这确实允许使用其他方法:

> 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    

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM