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

devtools::install_git fails to install dependencies of packages in Depends or Imports

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

1
2
3
4
5
6
** 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"?它存在于extrafont包中的Description文件中的"导入"列表中:

1
2
3
4
5
6
7
Depends:
    R (>= 2.15)
Imports:
    extrafontdb,
    grDevices,
    utils,
    Rttf2pt1

其他信息

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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 a€?C:/Users/SFirke/Documents/R/win-library/3.3a€?
(as a€?liba€? 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 a€?extrafonta€? successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\\Users\\SFirke\\AppData\\Local\\Temp\
tmpMlRSSR\\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)


问题:存在一些特定于Windows的问题,其中devtools 1.12.0(当前的CRAN版本)和devtools 1.12.0.9000的当前开发版本都存在嵌套/递归依赖项的问题(例如,您的程序包A依赖于依赖于软件包C的软件包B; devtools函数install_*(A)不会安装C)。

请参阅以下注释:开发版本和该线程的顶部,这些注释也说明了CRAN版本的问题,以及该程序包的手动指定要安装的子依赖项的解决方法。

解决方案:我安装了旧版本的devtools 1.11.1(于2016年4月发布),即使在缺少需要安装的依赖项的情况下,该工具也可用于我的上述install_git()调用。

1
2
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。