devtools :: install_git无法在Depends或Imports中安装软件包的依赖项

时间:2017-02-09 14:49:36

标签: r packages devtools

我有一个依赖于包extrafont的包。如果用户系统上没有extrafont及其依赖项Rttf2pt1,则我的软件包安装失败。我在我的包的描述文件中有extrafont作为“取决于”。当我运行devtools::install_git()从URL安装我的包时,输出终止于:

** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  there is no package called 'Rttf2pt1'
Error : package 'extrafont' could not be loaded
ERROR: lazy loading failed for package 'tntpr'
* removing 'C:/Users/SFirke/Documents/R/win-library/3.3/tntpr'

看起来像extrafont安装好了,但由于缺少Rttf2pt1而无效。当我将Rttf2pt1添加到我的DESCRIPTION文件的Depends列表中时,安装成功,同时安装extrafontRttf2pt1以及我的包。

为什么我需要将Rttf2pt1放入我的Depends列表中?它出现在extrafont包中的DESCRIPTION文件的“Imports”列表中:

Depends:
    R (>= 2.15)
Imports:
    extrafontdb,
    grDevices,
    utils,
    Rttf2pt1

其他信息

当我运行devtools::install_git("https://myurl.com/tntpr.git", dependencies = TRUE)时,我得到以下输出。它从GitHub安装dplyr,然后从外部安装,然后加载我的软件包失败:

Installing tntpr
Downloading GitHub repo hadley/dplyr@master
from URL https://api.github.com/repos/hadley/dplyr/zipball/master
Installing dplyr
"C:/PROGRA~1/R/R-33~1.2/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL  \
  "C:/Users/SFirke/AppData/Local/Temp/RtmpMlRSSR/devtools3dfc4e39620/hadley-dplyr-5902277" --library="C:/Users/SFirke/Documents/R/win-library/3.3" --install-tests 

* installing *source* package 'dplyr' ...
** libs

*** arch - i386
C:/RBuildTools/3.4/mingw_32/bin/g++  -I"C:/PROGRA~1/R/R-33~1.2/include" -DNDEBUG -I../inst/include -DCOMPILING_DPLYR   -I"C:/Users/SFirke/Documents/R/win-library/3.3/Rcpp/include" -I"C:/Users/SFirke/Documents/R/win-library/3.3/BH/include" -I"C:/Users/SFirke/Documents/R/win-library/3.3/bindrcpp/include" -I"C:/Users/SFirke/Documents/R/win-library/3.3/plogr/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c RcppExports.cpp -o RcppExports.o
<--- lots more lines like this ^^^^^ --->
** R
** data
*** moving datasets to lazyload DB
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
*** arch - i386
*** arch - x64
* DONE (dplyr)
Installing 1 package: extrafont
Installing package into ‘C:/Users/SFirke/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/extrafont_0.17.zip'
Content type 'application/zip' length 34323 bytes (33 KB)
downloaded 33 KB

package ‘extrafont’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\SFirke\AppData\Local\Temp\RtmpMlRSSR\downloaded_packages
"C:/PROGRA~1/R/R-33~1.2/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL "C:/Users/SFirke/AppData/Local/Temp/RtmpMlRSSR/file3dfc4a973a21"  \
  --library="C:/Users/SFirke/Documents/R/win-library/3.3" --install-tests 

* installing *source* package 'tntpr' ...
** R
** data
*** moving datasets to lazyload DB
** inst
** tests
** preparing package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  there is no package called 'Rttf2pt1'
Error : package 'extrafont' could not be loaded
ERROR: lazy loading failed for package 'tntpr'
* removing 'C:/Users/SFirke/Documents/R/win-library/3.3/tntpr'
Error: Command failed (1)

1 个答案:

答案 0 :(得分:2)

问题:特定于Windows的问题两者 devtools 1.12.0(当前的CRAN版本)当前的开发版本devtools 1.12.0.9000的嵌套/递归依赖性有问题(即,你的包A依赖于包B,它取决于包C; devtools函数install_*(A)不会安装C)。

请参阅此comment re: the development version以及线程的顶部部分,其中还指出了CRAN版本的问题以及要安装的this package's workaround of manually specifying sub-dependencies

解决方案:我安装了旧版本的devtools 1.11.1(2016年4月发布),该版本适用于上面的install_git()调用,即使缺少需要安装的依赖项

install.packages("devtools") # from CRAN
devtools::install_version("devtools", version = "1.11.1", repos = "http://cran.us.r-project.org") # get the old version

然后重新启动R并按预期使用devtools。