[英]Cannot install an R package from Github
我正在尝试运行devtools::install_github("gaborcsardi/notifier")
但 R 似乎没有正确识别 RTools; 它位于C:\\Rtools
。
按照https://github.com/r-lib/devtools/issues/1772上的说明操作后,使用 CRAN 版本的devtools
和pkgbuild
运行pkgbuild::find_rtools()
仍然给我以下错误:
Error in rethrow_call(c_processx_exec, command, c(command, args), stdin, : Command not found @win/processx.c:977
这是我的session_info()
:
- Session info ----------------------------------------------------------------------------------------------------------
setting value
version R version 3.5.2 (2018-12-20)
os Windows 10 x64
system x86_64, mingw32
ui RStudio
language (EN)
collate English_United States.1252
ctype English_United States.1252
tz America/Chicago
date 2019-09-03
- Packages --------------------------------------------------------------------------------------------------------------
! package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.3)
backports 1.1.4 2019-04-10 [1] CRAN (R 3.5.3)
bindr 0.1.1 2018-03-13 [2] CRAN (R 3.5.2)
bindrcpp 0.2.2 2018-03-29 [2] CRAN (R 3.5.2)
bit 1.1-14 2018-05-29 [1] CRAN (R 3.5.2)
bit64 0.9-7 2017-05-08 [1] CRAN (R 3.5.2)
blob 1.1.1 2018-03-25 [1] CRAN (R 3.5.3)
callr 3.3.1 2019-07-18 [1] CRAN (R 3.5.3)
cellranger 1.1.0 2016-07-27 [2] CRAN (R 3.5.2)
cli 1.1.0 2019-03-19 [1] CRAN (R 3.5.3)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.3)
curl 3.3 2019-01-10 [1] CRAN (R 3.5.3)
data.table 1.12.2 2019-04-07 [1] CRAN (R 3.5.3)
DBI 1.0.0 2018-05-02 [1] CRAN (R 3.5.3)
desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.3)
devtools * 2.1.0 2019-07-06 [1] CRAN (R 3.5.3)
digest 0.6.19 2019-05-20 [1] CRAN (R 3.5.3)
dplyr * 0.7.8 2018-11-10 [1] CRAN (R 3.5.2)
fs 1.3.1 2019-05-06 [1] CRAN (R 3.5.3)
D glue 1.3.1 2019-03-12 [1] CRAN (R 3.5.3)
hms 0.4.2 2018-03-10 [1] CRAN (R 3.5.3)
httr * 1.4.0 2018-12-11 [2] CRAN (R 3.5.2)
jsonlite 1.6 2018-12-07 [2] CRAN (R 3.5.2)
lubridate * 1.7.4 2018-04-11 [2] CRAN (R 3.5.2)
magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.3)
mailR * 0.4.1 2015-01-14 [1] CRAN (R 3.5.3)
memoise 1.1.0 2017-04-21 [2] CRAN (R 3.5.2)
odbc * 1.1.6 2018-06-09 [1] CRAN (R 3.5.2)
packrat 0.5.0 2018-11-14 [1] CRAN (R 3.5.3)
pillar 1.4.1 2019-05-28 [1] CRAN (R 3.5.3)
pkgbuild * 1.0.5 2019-08-26 [1] CRAN (R 3.5.3)
pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.5.3)
pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.3)
plyr 1.8.4 2016-06-08 [2] CRAN (R 3.5.2)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.3)
processx * 3.4.1 2019-07-18 [1] CRAN (R 3.5.3)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.3)
purrr 0.3.2 2019-03-15 [1] CRAN (R 3.5.3)
R.methodsS3 1.7.1 2016-02-16 [1] CRAN (R 3.5.2)
R.oo 1.22.0 2018-04-22 [1] CRAN (R 3.5.2)
R.utils 2.8.0 2019-02-14 [1] CRAN (R 3.5.3)
R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.3)
Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.5.3)
RDCOMClient * 0.93-0 2018-04-28 [1] local
readxl * 1.3.1 2019-03-13 [1] CRAN (R 3.5.3)
rematch 1.0.1 2016-04-21 [2] CRAN (R 3.5.2)
remotes 2.1.0 2019-06-24 [1] CRAN (R 3.5.3)
reshape * 0.8.8 2018-10-23 [1] CRAN (R 3.5.3)
D rJava 0.9-11 2019-03-29 [1] CRAN (R 3.5.3)
rlang 0.4.0 2019-06-25 [1] CRAN (R 3.5.3)
rprojroot 1.3-2 2018-01-03 [2] CRAN (R 3.5.2)
rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.5.3)
rvest * 0.3.4 2019-05-15 [1] CRAN (R 3.5.3)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.3)
splitstackshape * 1.4.8 2019-04-21 [1] CRAN (R 3.5.3)
stringi 1.4.3 2019-03-12 [1] CRAN (R 3.5.3)
stringr 1.4.0 2019-02-10 [1] CRAN (R 3.5.3)
D testthat 2.1.1 2019-04-23 [1] CRAN (R 3.5.3)
tibble 2.1.1 2019-03-16 [1] CRAN (R 3.5.3)
tidyr * 0.8.3 2019-03-01 [1] CRAN (R 3.5.3)
tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.5.3)
usethis * 1.5.0 2019-04-07 [1] CRAN (R 3.5.3)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.3)
writexl * 1.1 2018-12-02 [2] CRAN (R 3.5.2)
XML * 3.98-1.19 2019-03-06 [1] CRAN (R 3.5.2)
xml2 * 1.2.0 2018-01-24 [1] CRAN (R 3.5.3)
[1] \\termna.local/Shares/User Shares/Kyle.Dixon/Documents/R/win-library/3.5
[2] \\termna.local/Shares/User Shares/Kyle.Dixon/Documents/R/R-3.5.2/library
D -- DLL MD5 mismatch, broken installation.
实用程序(在 R 或其他语言/工具中)能够处理简单的文件路径和基于模式的 URL(例如, https://...
或file:///...
)并不少见,我认为同样处理 Windows 的 UNC 路径(即\\\\server\\share\\path
)的工具数量要少得多。 虽然我相信 R 在查找文件方面做得很好(否则你会因为只有两个.libPaths()
为 UNC 共享而遇到其他问题),但底层工具(包括gcc
)可能不会。
我认为前进的道路是将新软件包安装到不是网络共享的目录中。 我还认为这可以是一个临时位置,安装后的软件包可以移动/迁移到网络共享。
下面是一个简化临时目录创建、安装到该目录、然后移动到网络共享的功能。 (它实际上并不检查tgt
目录是否是网络共享,假设您不需要使用这是您的第一个库路径是本地的。)
#' Install a package(s) using a temp-local directory
#'
#' On Windows, if '.libPaths()' starts with a UNC network share,
#' package compilation might not work correctly. This function creates
#' a temporary local directory, executes the desired code in 'expr',
#' and moves any new packages into the normal first library path.
#'
#' @param expr expression such as 'install.packages("car")' or
#' 'devtools::install_github(...)'; the expression must natively
#' install into the first of '.libPaths()', but if you try something
#' like 'install.packages(.., lib="some/other/path"), then the
#' temporary libpath will not be used (and may fail)
#' @param tgt character, the directory to move the isntalled
#' package(s)
#' @param cleanup logical, whether to remove the temporary libpath
#' @return nothing
with_local_libpath <- function(expr, tgt = .libPaths()[1], cleanup = TRUE) {
if (length(tgt) > 1) {
warning("'tgt' must be length 1")
tgt <- tgt[[1]]
}
if (length(tgt) < 1 || !dir.exists(tgt)) {
stop("'tgt' must be length 1 and an existing directory")
}
dir.create(tmplib <- tempfile(pattern = "local_libpath_"))
message("Local (temp) libpath: ", sQuote(tmplib))
oldlib <- .libPaths()
.libPaths(c(tmplib, oldlib))
on.exit(.libPaths(oldlib), add = TRUE)
force(expr)
newstuff <- list.files(tmplib, full.names = TRUE)
if (length(newstuff)) {
newdirs <- file.path(oldlib[1], basename(newstuff))
message("New packages found: ", paste(sQuote(basename(newstuff)), collapse = ", "))
message("Moving to: ", sQuote(tgt))
file.copy(newstuff, tgt, recursive = TRUE)
if (cleanup) {
message("Cleaning up")
unlink(tmplib, recursive = TRUE)
}
} else {
message("No new packages found (?)")
}
invisible()
}
我用一些简单的例子对此进行了测试,但不是广泛的,所以请注意空客。 我没有网络安装的 lib-path,所以我会强制一个(到我维护的服务器):
.libPaths(c("\\\\myserver/r2evans/R/win.library/3.5", .libPaths()))
安装失败:
remotes::install_github("gaborcsardi/notifier@d92b1b6")
# Downloading GitHub repo gaborcsardi/notifier@d92b1b6
# v checking for file 'C:\Users\r2\AppData\Local\Temp\RtmpWgKbkW\remotes43cc57193c83\gaborcsardi-notifier-d92b1b6/DESCRIPTION' (377ms)
# - preparing 'notifier':
# v checking DESCRIPTION meta-information
# - checking for LF line-endings in source and make files and shell scripts
# - checking for empty or unneeded directories
# - building 'notifier_1.0.0.tar.gz'
#
# Installing package into '\\myserver/r2evans/R/win.library/3.5'
# (as 'lib' is unspecified)
# * installing *source* package 'notifier' ...
# ** R
# ** inst
# Error in file.create(to[okay]) :
# (converted from warning) cannot create file '\myserver/r2evans/R/win.library/3.5/notifier/R.ico', reason 'No such file or directory'
# * removing '\\myserver/r2evans/R/win.library/3.5/notifier'
# In R CMD INSTALL
# Error: Failed to install 'notifier' from GitHub:
# (converted from warning) installation of package 'C:/Users/r2/AppData/Local/Temp/RtmpWgKbkW/file43cc60c05cc/notifier_1.0.0.tar.gz' had non-zero exit status
(我选择了一个特定版本,因为https://github.com/gaborcsardi/notifier/issues/22 。虽然错误与您的错误不同,但我怀疑失败是出于类似/相关的原因。)
安装成功:
with_local_libpath(remotes::install_github("gaborcsardi/notifier@d92b1b6"))
# Local (temp) libpath: 'C:\Users\r2\AppData\Local\Temp\RtmpWgKbkW\local_libpath_43ccbf98e2'
# Downloading GitHub repo gaborcsardi/notifier@d92b1b6
# v checking for file 'C:\Users\r2\AppData\Local\Temp\RtmpWgKbkW\remotes43cc7cb66d1f\gaborcsardi-notifier-d92b1b6/DESCRIPTION' (396ms)
# - preparing 'notifier':
# v checking DESCRIPTION meta-information
# - checking for LF line-endings in source and make files and shell scripts
# - checking for empty or unneeded directories
# - building 'notifier_1.0.0.tar.gz'
#
# Installing package into 'C:/Users/r2/AppData/Local/Temp/RtmpWgKbkW/local_libpath_43ccbf98e2'
# (as 'lib' is unspecified)
# * installing *source* package 'notifier' ...
# ** R
# ** inst
# ** byte-compile and prepare package for lazy loading
# ** help
# *** installing help indices
# converting help for package 'notifier'
# finding HTML links ... done
# notify html
# ** building package indices
# ** testing if installed package can be loaded
# *** arch - i386
# *** arch - x64
# * DONE (notifier)
# In R CMD INSTALL
# New packages found: 'notifier'
# Moving to: '\\myserver/r2evans/R/win.library/3.5'
# Cleaning up
remotes
有一个独立模式。 这种模式消除了对pkgbuild
的依赖,这是错误的直接原因(最终问题在调用链中更深层次)。
您可以强制remotes
使用独立模式
Sys.setenv(R_REMOTES_STANDALONE="true")
感谢gaborcsardi找到了这个解决方案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.