【问题标题】:Setting proxy on .Rprofile on OSX fails在 OSX 上的 .Rprofile 上设置代理失败
【发布时间】:2011-04-12 08:55:31
【问题描述】:

为了从我一直在使用的 OSX 上的 R 中访问 CRAN 包

Sys.setenv(http_proxy="http://blah_blah:1234/")

作为 R GUI 中的第一个命令有一段时间,但真的很想自动设置这个代理。

我尝试让相同的命令在 ~/ 中的 .Rprofile 文件中工作,但没有成功

我也试过http_proxy="http://blah_blah:1234/",但这也失败了。

我在尝试查看包时遇到的错误是一个下拉窗口,上面写着:

Fetching Package List Failed
Please consult R Console output for details

GUI 然后给出:

Error in read.dcf(file = tmpf) : Line starting '<head> ...' is malformed!

.Rprofile 文件本身似乎正在加载(使用cat("my profile works\n"))检查

【问题讨论】:

  • 有人会创建一个 rprofile 标签吗?现在有几个问题与 rprofile 直接相关
  • 启动 R 后,输入:Sys.getenv("http_proxy")
  • 如果是设置下载包的仓库,可以在profile文件中使用options("repos"="http://cran.stat.ucla.edu/")
  • @csgillespie Sys.getenv("http_proxy") 返回 http_proxy ""

标签: macos r proxy rprofile


【解决方案1】:

【讨论】:

  • 我首先在 .Rprofile 中尝试过,但无法正常工作 - 这是错的吗?
【解决方案2】:

在 OS X 上搜索设置 R 代理时,此线程首先出现,所以这是我在 .Rprofile 中使用的内容:

Sys.setenv(http_proxy=system("networksetup -getwebproxy Ethernet | awk {'print $2'} | awk {'getline l2; getline l3; print \"http://\"l2\":\"l3'} | head -n 1",intern=TRUE))

如有必要,将以太网更改为机场

awk 部分的功劳归Chealion

【讨论】:

    【解决方案3】:

    我想我已经设法通过反复试验解决了这个问题......

    .First Sys.setenv() 的组合有效。

    如果有人有任何想法,我很想知道为什么。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多