我正在GitHub上开发两个软件包,尝试使用devtools::install_github()
命令安装它们。
由于这些存储库是私有的,我为我的帐户创建了一个auth_token
(据我所知,没有办法为单个存储库创建此类令牌?)。
devtools::install_github("mariodejung/rMQanalysis",
auth_token="6cd2dbe8bd1f062842b90afXXXXXXXXXXXXXXXXX",
ref="develop",
dependencies=TRUE)
devtools::install_github("mariodejung/cfpscripts",
auth_token="6cd2dbe8bd1f062842b90afXXXXXXXXXXXXXXXXX",
ref="develop")
安装第一个包的过程如预期一样,但是安装第二个包时出现错误并且提到了第一个已经安装好的包。请看结尾处的评论中的错误信息。
我重新添加了下面的错误信息,因为我已经进行了一些更改。
抱歉更改了auth_token
,但现在脚本应该保持私密状态。
我也尝试过用一个命令同时安装这两个包,但结果是相同的错误信息。我还按照评论提示,在我的环境中添加了GITHUB_PAT
变量,以免公开使用认证令牌。
devtools::install_github(c("mariodejung/rMQanalysis","mariodejung/cfpscripts"),
ref="develop",
dependencies=TRUE)
这个命令现在可以成功安装rMQanalysis
包,但是在安装cfpscripts
时会出现相同的错误信息导致安装失败。仍然不知道如何找出问题所在,因为它在其他机器上可以正常运行,并且所有依赖项都已经安装好了。
devtools::install_github(c("mariodejung/rMQanalysis","mariodejung/cfpscripts"), ref='develop', quiet=FALSE)
Using GitHub PAT from envvar GITHUB_PAT
Downloading GitHub repo mariodejung/rMQanalysis@develop
from URL https://api.github.com/repos/mariodejung/rMQanalysis/zipball/develop
Installing rMQanalysis
"C:/PROGRA~1/R/R-32~1.5/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL \
"C:/Users/cfproteomics/AppData/Local/Temp/RtmpktvmUK/devtools43850da641a/mariodejung-rMQanalysis-0e38dd3463ea830b19f0afa2ade6f2e14db93041" \
--library="C:/Users/cfproteomics/Documents/R/win-library/3.2" --install-tests
* installing *source* package 'rMQanalysis' ...
** R
** data
*** moving datasets to lazyload DB
** inst
** tests
** preparing package for lazy loading
** help
No man pages found in package 'rMQanalysis'
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
*** arch - i386
*** arch - x64
* DONE (rMQanalysis)
Downloading GitHub repo mariodejung/cfpscripts@develop
from URL https://api.github.com/repos/mariodejung/cfpscripts/zipball/develop
Installing cfpscripts
Downloading GitHub repo mariodejung/rMQanalysis@develop
from URL https://api.github.com/repos/mariodejung/rMQanalysis/zipball/develop
Error in stop(github_error(request)) : Not Found (404)
我也使用了traceback()
函数,但它没有提供更多的见解...
15: stop(github_error(request))
14: download_github(dest, src, auth)
13: remote_download.github_remote(remote, quiet = quiet)
12: remote_download(remote, quiet = quiet)
11: FUN(X[[i]], ...)
10: vapply(remotes, install_remote, ..., FUN.VALUE = logical(1))
9: install_remotes(object$remote[behind], ..., quiet = quiet)
8: update.package_deps(pkg, ..., Ncpus = threads, quiet = quiet,
upgrade = upgrade)
7: update(pkg, ..., Ncpus = threads, quiet = quiet, upgrade = upgrade)
6: install_deps(pkg, dependencies = initial_deps, upgrade = upgrade_dependencies,
threads = threads, force_deps = force_deps, quiet = quiet,
...)
5: install(source, ..., quiet = quiet, metadata = metadata)
4: FUN(X[[i]], ...)
3: vapply(remotes, install_remote, ..., FUN.VALUE = logical(1))
2: install_remotes(remotes, quiet = quiet, ...)
1: devtools::install_github(c("mariodejung/rMQanalysis", "mariodejung/cfpscripts"),
ref = "develop", quiet = FALSE)
更新2
整个问题似乎是 devtools 1.12.0
中的一个错误。在 1.11.1
中运行良好。
我发现,我的 rMQanalysis
包在 cfpscripts
中被称为 Imports:
。如果我从 Description
中删除这个 Imports:
语句,则该包可以成功安装。
我仍然想知道为什么我不能设置 dependencies=FALSE
来防止 install_github
安装依赖包。
我已经在 devtools 上提交了错误报告,但还没有反应。
~/.Renviron
文件中的GITHUB_PAT
变量中(需要重新启动R以便将.Renviron
中的数据加载到环境中)。这样做可以节省大量打字时间,有助于防止信息泄露,也可能有助于解决此问题。 - hrbrmstrGITHUB_PAT
,我之前不知道。但这并没有解决问题。仍然出现相同的错误,但注释中显示“从环境变量GITHUB_PAT使用GitHub PAT”。 - drmariodGITHUB_PAT
方法解决了这个问题。请注意,remotes
包还支持通过DESCRIPTION中的Remotes:
字段明确声明github依赖项。请参见此处。 - Niels