Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Install R package from GitHub in package vignette

$
0
0

I've built an R package and it's available on CRAN. I am updating one of the vignettes and I would like to install a package from GitHub in the vignette. The R CMD Checks ran smoothly on my machine, but after submission to CRAN I received a message indicating that I need to install the package to a temporary library.

I used this code to attempt to install the package to a temporary directory. The code works on my local machine and the R CMD Checks pass locally (devtools::check() and devtools::check(remote = TRUE)). But the checks fail when run on the CRAN machine (rhub::check_for_cran()).

# adding temp_path to .libPaths
temp_path <- file.path(tempdir(), "gt_folder"); dir.create(temp_path)
lib_path <-.libPaths()
.libPaths(c(lib_path, temp_path))

remotes::install_github("rstudio/gt", lib = temp_path)

gt::gt(mtcars)

This is the error I see from rhub::check_for_cran(). It seems the dependencies are not being handled correctly.

   ERROR: dependencies 'lazyeval', 'reshape2', 'scales', 'tibble' are not available for package 'ggplot2'
-  removing 'C:/Users/USERVzKWFkopnQ/AppData/Local/Temp/RtmpIjoZQH/working_dir/RtmpiwGvJu/gt_folder/ggplot2'
   ERROR: dependencies 'fansi', 'utf8', 'vctrs' are not available for package 'pillar'
-  removing 'C:/Users/USERVzKWFkopnQ/AppData/Local/Temp/RtmpIjoZQH/working_dir/RtmpiwGvJu/gt_folder/pillar'

   The downloaded source packages are in
    'C:\Users\USERVzKWFkopnQ\AppData\Local\Temp\RtmpIjoZQH\working_dir\RtmpiwGvJu\downloaded_packages'
   ERROR: dependencies 'checkmate', 'commonmark', 'dplyr', 'fs', 'ggplot2', 'sass', 'scales', 'tibble', 'tidyselect' are not available for package 'gt'
-  removing 'C:/Users/USERVzKWFkopnQ/AppData/Local/Temp/RtmpIjoZQH/working_dir/RtmpiwGvJu/gt_folder/gt'
   Quitting from lines 18-45 (install_from_github.Rmd) 
   Error: processing vignette 'install_from_github.Rmd' failed with diagnostics:
   there is no package called 'gt'
   --- failed re-building 'install_from_github.Rmd'

   SUMMARY: processing the following file failed:
     'install_from_github.Rmd'

   Error: Vignette re-building failed.
   Execution halted

Here's a light-weight package with only one function and a vignette illustrating the problem https://github.com/ddsjoberg/pkginstallgh

Here is the note I received from CRAN

Dear maintainer,

Pls see
<https://cran.r-project.org/web/checks/check_results_gtsummary.html>.

The check problems on the Debian systems are caused by attempts to write
to the user library to which all packages get installed before checking
(and which now is remounted read-only for checking).

Having package code which is run as part of the checks and attempts to
write to the user library violates the CRAN Policy's

  Packages should not write in the user’s home filespace (including
  clipboards), nor anywhere else on the file system apart from the R
  session’s temporary directory (or during installation in the location
  pointed to by TMPDIR: and such usage should be cleaned up).

In your case, you need to teach remotes::install_github("rstudio/gt") to
install to a temporary library and use it from there.

Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>