简体   繁体   中英

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

I have a package that depends on the package extrafont . If extrafont and its dependency Rttf2pt1 aren't present on the user's system, installation of my package fails. I have extrafont as "Depends" in my package's DESCRIPTION file. When I run devtools::install_git() to install my package from a URL, the output terminates with:

** 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'

Looks like extrafont installs okay, but doesn't work because Rttf2pt1 is missing. When I add Rttf2pt1 to the Depends list in my DESCRIPTION file, then the installation succeeds, installing both extrafont and Rttf2pt1 and my package.

Why do I need to put Rttf2pt1 in my Depends list? It's present on the "Imports" list in the DESCRIPTION file from the extrafont package:

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

Additional info

When I run devtools::install_git("https://myurl.com/tntpr.git", dependencies = TRUE) , I get the following output. It installs dplyr from GitHub, then extrafonts, then fails loading my package:

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)

The problem: There are issues specific to Windows where both devtools 1.12.0 (the current CRAN version) and the current development version of devtools 1.12.0.9000 have trouble with nested / recursive dependencies (ie, say your package A depends on package B which depends on package C; devtools functions install_*(A) will not install C).

See this comment re: the development version and the top parts of the thread that note problems with the CRAN version as well and this package's workaround of manually specifying sub-dependencies to install.

Solution : I installed an old version of devtools 1.11.1 (released April 2016), which works for my install_git() call above even when there are dependencies missing that need to be installed.

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

Then restart R and use devtools as intended.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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