Building With `devtools` Suddenly Fails for Vignettes

  64-bit, devtools, installation, r, windows

Context

I’ve been developing an R package (call it my_pkg) with vignettes, on a Lenovo ThinkPad with the following software

       sysname        release        version       machine
     "Windows"       "10 x64"  "build 19043"      "x86-64"

as provided by Sys.info().

Until recently, my devtools workflow has been reasonably smooth (with one occasional exception). However, I’ve begun to encounter a very puzzling error, which occurs under conditions virtually identical to those beforehand, when the workflow proceeded without issue.

With devtools::check()

When I run devtools::check(), everything starts promisingly…

i Updating my_pkg documentation
i Loading my_pkg
Writing NAMESPACE
Writing NAMESPACE
-- Building --------------------------------------------------------------------------------- my_pkg --
Setting env vars:
* CFLAGS    : -Wall -pedantic
* CXXFLAGS  : -Wall -pedantic
* CXX11FLAGS: -Wall -pedantic
-------------------------------------------------------------------------------------------------------
√  checking for file 'C:UsersgregWorkspaceRPackagesmy_pkg/DESCRIPTION' ...
-  preparing 'my_pkg': (733ms)
√  checking DESCRIPTION meta-information ... 
-  installing the package to build vignettes
         -----------------------------------
-  installing *source* package 'my_pkg' ...
   ** using staged installation
   ** R
   ** inst
   ** byte-compile and prepare package for lazy loading
   ** help
   *** installing help indices
     converting help for package 'my_pkg'
       finding HTML links ... done 
       foo                                     html
       my_pkg-package                          html
   *** copying figures
   ** building package indices
   ** installing vignettes
   ** testing if installed package can be loaded from temporary location

…until the step testing if installed package can be loaded from temporary location. Here an error occurs:

   Error : package 'my_pkg' is not installed for 'arch = x64'
   Error: loading failed
   Execution halted
   ERROR: loading failed
-  removing 'C:/Users/greg/AppData/Local/Temp/RtmpSaabgx/Rinst332419517258/my_pkg'
         -----------------------------------
   ERROR: package installation failed
Error in (function (command = NULL, args = character(), error_on_status = TRUE,  : 
  System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr (last 10 lines):
E> ** building package indices
E> ** installing vignettes
E> ** testing if installed package can be loaded from temporary location
E> Error : package 'my_pkg' is not installed for 'arch = x64'
E> Error: loading failed
E> Execution halted
E> ERROR: loading failed
E> * removing 'C:/Users/greg/AppData/Local/Temp/RtmpSaabgx/Rinst332419517258/my_pkg'
E>       -----------------------------------
E> ERROR: package installation failed
Type .Last.error.trace to see where the error occurred

I have no clue as to why the architecture

Error : package 'my_pkg' is not installed for 'arch = x64'

should be an issue only now. There have been no substantive changes to my computer.

Despite the message package installation failed, and despite the fact that I’ve run devtools::check() rather than devtools::install(), the package acts as if it were "halfway" installed! I can type my_p in the console, and RStudio will autocomplete my_pkg; and I can then type my_pkg:: and RStudio will supply the standard autocompletion list of the functions in my_pkg, which are all available.

However, typing my_pkg:: not only summons the @exported functions but also exposes my internal functions and data, as if I had typed my_pkg:::!

With devtools::install() or devtools::build(vignettes = FALSE)

Oddly, when I actually run devtools::install(), or comparably devtools::build_vignettes(vignettes = FALSE), the process completes without a hitch!

√  checking for file 'C:UsersgregWorkspaceRPackagesmy_pkg/DESCRIPTION' ...
-  preparing 'my_pkg': (640ms)
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts (384ms)
-  checking for empty or unneeded directories
   Removed empty directory 'my_pkg/inst/libs'
   Omitted 'LazyData' from DESCRIPTION
-  building 'my_pkg_0.0.0.9000.tar.gz'
   
Running "C:/Users/greg/R/bin/x64/Rcmd.exe" INSTALL 
  "C:UsersgregAppDataLocalTempRtmpozvh26/my_pkg_0.0.0.9000.tar.gz" --install-tests 
* installing to library 'C:/Users/greg/R/library'
* installing *source* package 'my_pkg' ...
** using staged installation
** R
** inst
** tests
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
  converting help for package 'my_pkg'
    finding HTML links ... done
       foo                                     html
       my_pkg-package                          html
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
*** arch - i386
*** arch - x64
** testing if installed package can be loaded from final location
*** arch - i386
*** arch - x64
** testing if installed package keeps a record of temporary installation path
* DONE (my_pkg)
Making 'packages.html' ... done

Now, the autocompletion works entirely as expected, and only the appropriate functions are exposed by my_pkg:: and my_pkg::: respectively.

With devtools::install(build_vignettes = TRUE) or devtools::build()

Yet there is one further plot twist. When I use devtools::install(build_vignettes = TRUE), or comparably devtools::install(), I get a similar error to that with devtools::check():

√  checking for file 'C:UsersgregWorkspaceRPackagesmy_pkg/DESCRIPTION' ...
-  preparing 'my_pkg': (672ms)
√  checking DESCRIPTION meta-information ... 
-  installing the package to build vignettes
         -----------------------------------
-  installing *source* package 'my_pkg' ...
   ** using staged installation
   ** R
   ** inst
   ** byte-compile and prepare package for lazy loading
   ** help
   *** installing help indices
     converting help for package 'my_pkg'
       finding HTML links ... done
       foo                                     html
       my_pkg-package                          html
   *** copying figures
   ** building package indices
   ** installing vignettes
   ** testing if installed package can be loaded from temporary location

   Error : package 'my_pkg' is not installed for 'arch = x64'
   Error: loading failed
   Execution halted
   ERROR: loading failed
-  removing 'C:/Users/greg/AppData/Local/Temp/RtmpM7RbHr/Rinst504119422cd/my_pkg'
         -----------------------------------
   ERROR: package installation failed
Error in (function (command = NULL, args = character(), error_on_status = TRUE,  : 
  System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr (last 10 lines):
E> ** building package indices
E> ** installing vignettes
E> ** testing if installed package can be loaded from temporary location
E> Error : package 'my_pkg' is not installed for 'arch = x64'
E> Error: loading failed
E> Execution halted
E> ERROR: loading failed
E> * removing 'C:/Users/greg/AppData/Local/Temp/RtmpM7RbHr/Rinst504119422cd/my_pkg'
E>       -----------------------------------
E> ERROR: package installation failed
Type .Last.error.trace to see where the error occurred

Note

Assuming that the fault was mine, and that I had unwittingly introduced an issue somewhere within my R project, I switched to an entirely different Git branch. The most recent commit to this branch had passed devtools::check() with flying colors. However, even after switching over to this "safe" branch, those same issues continued!

Between that last successful check and when the issues began, I made no updates to

  • R itself
  • RStudio
  • Any R packages
  • My computer’s software
  • My computer’s hardware

and the vignettes have been present since far earlier in the project.

Conclusion

I’m hoping to roll out a proof of concept for my_pkg in the rather near future, and the vignettes are quite essential to its usability. I would be very grateful for a prompt diagnosis, and I am happy to supply further information where needed.

Any help would be greatly appreciated!

Source: Windows Questions

LEAVE A COMMENT