devtools::check install failure, can't find a package already installed

I am running the check() function (devtools::check(document = FALSE, args = c('--no-manual')) on my package, but it fails with the following error :

E  checking whether package 'DIANE' can be installed (5s)
   Installation failed.
   See 'D:/These/DIANE.Rcheck/00install.out' for details.
   for details.

-- Install failure -------------------------------------------------------------

* installing *source* package 'DIANE' ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  there is no package called 'MASS'
Calls: <Anonymous> ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
ERROR: lazy loading failed for package 'DIANE'
* removing 'D:/These/DIANE.Rcheck/DIANE'

However, I have already installed the package MASS, it is in the classic R libraries path, and can be loaded without any problem from my R console.

Running the "Install and restart" button in RStudio (Rcmd.exe INSTALL --no-multiarch --with-keep.source DIANE) on my package also works perfectly fine :

* installing to library 'C:/Users/Oceane/Documents/R/win-library/4.0'
* installing *source* package 'DIANE' ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
  converting help for package 'DIANE'
*** installing help indices
    finding HTML links ...    draw_MDS                                html  
    draw_coseq_run                          html  
    draw_distributions                      html  
    draw_heatmap                            html  
    estimateDEGs                            html   done

    estimateDispersion                      html  
    filter_sum                              html  
    normalize                               html  
    plotDEGs                                html  
    run_app                                 html  
    run_coseq                               html  
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path

I tried to use non-staged intallation but the check also fails with the same error on MASS.

I am using rstudio v1.3.947, and R v4.0.0. The version of the concerned packages :
devtools_2.3.0 usethis_1.6.1 MASS_7.3-51.6
Do you have any idea on what is causing that behavior and how to solve it?

Does running rcmdcheck::rcmdcheck() solve the issue? If it does, the problem is likely somewhere on the devtools::check pipeline (check calls rcmdcheck through check_built). I am having the same problem (failure to recognize the MASS package), but unfortunately just reinstalling devtools doesn't solve it.

I have finally found a solution for my case, hopefully this is useful for more people:

I've noticed that .Library wasn't pointing to where I usually install my packages (~/R/x86_64-pc-linux-gnu-library/4.0/), but to a system folder (/usr/lib/R/library) containing some other basic packages (not MASS, though). That's where devtools::check was looking for a MASS installation. Thus, the solution was to:

  1. Run R with superuser privilege
  2. Explicitly install MASS to the folder indicated in .Library: install.packages('MASS', lib='/usr/lib/R/library')
  3. Quit R and reopen it as a normal user.

After step 3, devtools::check ran as expected.

1 Like

Thank you wleoncio, following the steps of your solution worked perfectly for me!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.