简体   繁体   English

install.packages("devtools") 失败

[英]install.packages("devtools") fails

I'm new to installing packages and R, It looks like my devtools library is missing.我是安装包和 R 的新手,看起来我的 devtools 库丢失了。

I was trying to install swirl, I got the following message:我正在尝试安装 swirl,但收到以下消息:

> install.packages("swirl")
Installing package into ‘C:/Users/cory/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Warning: failed to download mirrors file (cannot open destfile 'C:\Users\cory\AppData\Local\Temp\RtmpuA5tgZ\filef6c6874433a', reason 'No such file or directory'); using local file 'C:/PROGRA~1/R/R-35~1.1/doc/CRAN_mirrors.csv'
Warning: unable to access index for repository https://cran.cnr.berkeley.edu/src/contrib:
  cannot open destfile 'C:\Users\cory\AppData\Local\Temp\RtmpuA5tgZ\filef6c4b9547', reason 'No such file or directory'
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning messages:
1: package ‘swirl’ is not available (for R version 3.5.1) 
2: In gzfile(file, mode) :
  cannot open compressed file 'C:\Users\cory\AppData\Local\Temp\RtmpuA5tgZ/libloc_194_4cc5b48b.rds', probable reason 'No such file or directory'

I then tried the following:然后我尝试了以下操作:

> library(devtools)
Error in library(devtools) : there is no package called ‘devtools’

So I downloaded devtools in zip format and tried loading it所以我下载了 zip 格式的 devtools 并尝试加载它

> getwd()
[1] "C:/Users/cory/Documents"

I downloaded the devtools zip in the same folder, and renamed it to devtoolz zip I tried running the command again我在同一文件夹中下载了 devtools zip,并将其重命名为 devtoolz zip 我再次尝试运行该命令

> install.packages("devtools")
Installing package into ‘C:/Users/cory/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository http://cran.rstudio.com/src/contrib:
  cannot open destfile 'C:\Users\cory\AppData\Local\Temp\RtmpuA5tgZ\filef6c77f36a9', reason 'No such file or directory'
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning messages:
1: package ‘devtools’ is not available (for R version 3.5.1) 
2: In gzfile(file, mode) :
  cannot open compressed file 'C:\Users\cory\AppData\Local\Temp\RtmpuA5tgZ/libloc_194_4cc5b48b.rds', probable reason 'No such file or directory'

What steps should I take to get the devtools installed?我应该采取什么步骤来安装 devtools? Many thanks: :)非常感谢: :)

I found a way around this, In case it helps someone else:我找到了解决这个问题的方法,以防它帮助别人:

*In Rstudio, it tuns out it is possible to install a package without downloading locally and without pointing to an URL (which I also had tried). *在 Rstudio 中,它表明可以在不在本地下载和不指向 URL 的情况下安装包(我也试过)。 Because it is integrated with CRAN-mirrors, I was able to simply type devtools in the box and select it from the existing drop-down menu.因为它与 CRAN 镜像集成,所以我可以简单地在框中键入 devtools 并从现有的下拉菜单中选择它。

It proved more efficient than trying to manually import it through RGui.*事实证明,它比尝试通过 RGui 手动导入更有效。*

I had the same issue, I just closed my RStudio and opened it, and it worked.我有同样的问题,我只是关闭了我的 RStudio 并打开它,它起作用了。

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

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