Search code examples
rpackage-development

pkgdown R package build_site function causes dependent packages unable to be loaded


I am using pkgdown package to generate the elegant and static manual page for R package (called RTCGA). When I run the code to produce the static documentation as website I use following commands

> pkgdown::build_site()
Initialising site -------------------------------------------------------------------------------------
Copying '/home/mkosinski/R/x86_64-pc-linux-gnu-library/3.3/pkgdown/assets/jquery.sticky-kit.min.js'
Copying '/home/mkosinski/R/x86_64-pc-linux-gnu-library/3.3/pkgdown/assets/link.svg'
Copying '/home/mkosinski/R/x86_64-pc-linux-gnu-library/3.3/pkgdown/assets/pkgdown.css'
Copying '/home/mkosinski/R/x86_64-pc-linux-gnu-library/3.3/pkgdown/assets/pkgdown.js'
Building home -----------------------------------------------------------------------------------------
Writing '/home/mkosinski/GitHub/RTCGA/docs/index.html'
Building function reference ---------------------------------------------------------------------------
Loading RTCGA
Welcome to the RTCGA (version: 1.5.1).
trying URL 'http://gdac.broadinstitute.org/runs/stddata__2015_11_01/data/ACC/20151101/gdac.broadinstitute.org_ACC.Merge_mirnaseq__illuminahiseq_mirnaseq__bcgsc_ca__Level_3__miR_gene_expression__data.Level_3.2015110100.0.0.tar.gz'
Content type 'unknown' length 309876 bytes (302 KB)
==================================================
downloaded 302 KB

Warning: Topics missing from index: RTCGA-package, theme_RTCGA
Building articles -------------------------------------------------------------------------------------
Building article 'RTCGA_Workflow.html'
Building article 'Web_Applications.html'

This code is evaluated in the root of RTCGA package project and gives information that RTCGA was loaded and the documentation was created.

But I have found a bug in the documentation in most pages - there is an error telling

Error: package ‘RTCGA’ required by ‘RTCGA.rnaseq’ could not be found

enter image description here

So none of examples can be run. Moreover when I run library(RTCGA.rnaseq) after I used build_site I can not load dependent RTCGA package anymore

> library(RTCGA)
> library(RTCGA.rnaseq)
Error: package ‘RTCGA’ required by ‘RTCGA.rnaseq’ could not be found

When I run library(RTCGA.rnaseq) in the new session without calling the pkgdown::build_site the dependent RTCGA package loads normally with no warnings.

I suspect that this is caused by any settings that build_site performs but I have no idea on how to resolve them and how to build proper static documentation with the usage of pkgdown package.

Any comments?


Solution

  • It looks like I have found a nasty work-around. RTCGA software package uses 8 data packages in its examples. Each data package required RTCGA to be loaded. pkgdown::build_site() uses devtools::load_all() which weirdly loads only objects from RTCGA but does not allow to load this package during examples run.

    I have removed RTCGA from Depends of the data packages by changing those packages meta-informations like

    packages_to_remove_RTCGA_from_Depends <- 
      c("RTCGA.clinical",
        "RTCGA.mutations",
        "RTCGA.rnaseq",
        "RTCGA.RPPA",
        "RTCGA.mRNA",
        "RTCGA.miRNASeq",
        "RTCGA.methylation",
        "RTCGA.CNV")
    
    sapply(packages_to_remove_RTCGA_from_Depends, function(data_package){
      Meta <- readRDS(file.path(.libPaths()[1], data_package, "Meta", "package.rds"))
      Meta$Depends <- list()
      saveRDS(Meta, file.path(.libPaths()[1], data_package, "Meta", "package.rds"))
    })