R 更新后无法安装软件包:无法访问存储库的索引:无法加载 Internet 例程

Nat*_*ght 8 r repository install.packages

我使用 RStudio,昨天我将 R 更新为以下版本:

R version 4.0.0 (2020-04-24) -- "Arbor Day"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
Run Code Online (Sandbox Code Playgroud)

现在,我无法连接到任何 CRAN 镜像(我已经尝试了 4 个不同的镜像)或安装软件包。当我启动 RStudio 时,我在启动时收到以下错误:

Error in tools::startDynamicHelp() : internet routines cannot be loaded
Warning: namespace ‘lme4’ is not available and has been replaced
by .GlobalEnv when processing object ‘lmer1’
Warning: namespace ‘ggplot2’ is not available and has been replaced
by .GlobalEnv when processing object ‘plot1’
Warning: namespace ‘emmeans’ is not available and has been replaced
by .GlobalEnv when processing object ‘.Last.ref_grid’
Warning: namespace ‘pbkrtest’ is not available and has been replaced
by .GlobalEnv when processing object ‘.Last.ref_grid’
[Workspace loaded from C:/Users/xxx.RData]

Loading required package: lmerTest
Loading required package: lme4
Loading required package: Matrix
Error: package or namespace load failed for ‘lme4’:
 package ‘lme4’ was installed before R 4.0.0: please re-install it
Failed with error:  ‘package ‘lme4’ could not be loaded’
Run Code Online (Sandbox Code Playgroud)

然后,当我尝试安装软件包时,我收到以下消息:

Installing package into ‘C:/Users/xxx/R/win-library/4.0’
(as ‘lib’ is unspecified)
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/src/contrib:
  internet routines cannot be loaded
Warning in install.packages :
  package ‘Rtools’ is not available (for R version 4.0.0)
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/bin/windows/contrib/4.0:
  internet routines cannot be loaded
Run Code Online (Sandbox Code Playgroud)

我知道这些警告有多个线程,但我还没有在其中任何一个上找到解决此问题的方法。我已经尝试过但没有奏效的事情:

  • 更改 CRAN 镜像设置 - 我尝试了 4 种不同的镜像,并且镜像可以正常工作,因为它可以在另一台计算机上运行
  • 重新启动程序
  • 重新启动计算机
  • 更改工具>全局选项>包中的设置,以便取消选中https
  • 更新 RStudio(虽然这也是 R 中的一个问题)
  • 卸载并重新安装 R 4.0
  • 检查库路径 - 似乎正确
  • 使 Internet Explorer 成为默认浏览器
  • 运行命令 options(repos='https://cran.rstudio.com/')
  • 运行命令行 install.packages("package name", dependencies=TRUE, repos='http://cran.rstudio.com/')
  • 运行命令 options(download.file.method="libcurl")
  • 运行命令 Sys.getenv("LD_LIBRARY_PATH")

我的伙伴将 R 4.0 和 RStudio 下载到他的计算机上,并且运行良好。

有什么建议?我是 Stack Overflow 的新手,也是 R 的新手,所以请尽可能分步说明/建议!

小智 13

我有一个类似的问题。我在启动时收到以下错误

Error in tools::startDynamicHelp() : internet routines cannot be loaded

经过调查,我发现我的杀毒软件已经隔离了R-4.0.0/modules/x64/internet.dll. 不幸的是,我的防病毒设置由组策略控制,因此我无法禁用它们来寻求解决方案。

  • 是的,可以确认这是一个问题。作为目前的解决方案,对我有用的是使用以前的 3.6.1 安装中的 x64 internet.dll 并将其复制到 R-4.0.0/modules/x64/ 或者,如果不需要 x64,则在 RStudio 中选择 x86 (4认同)

Nat*_*ght 7

因此,在打了 4 个电话并多次尝试解决这个问题之后,我的机构 IT 部门今天能够禁用阻止 R 和 R Studio 工作的防病毒块。

显然,为了避免将来发生这种情况,我需要从特定文件夹运行新程序。所以它毕竟是防病毒软件,但由于我有一台工作计算机,因此我无法更改设置。


小智 7

我通过简单地运行[每次]来解决这个问题:

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