pacman icon indicating copy to clipboard operation
pacman copied to clipboard

Incorrect handling of `force = FALSE` when installing multiple packages using `p_install`

Open r-cheologist opened this issue 6 years ago • 3 comments

Consider the following:

  1. Pacman isn't present:

     > "pacman" %in% installed.packages()
     [1] FALSE
    
  2. Neither is dplyr:

    > "dplyr" %in% installed.packages()      
    [1] FALSE
    
  3. Install pacman:

    > install.packages("pacman")
    ...
    * installing *source* package ‘pacman’ ...
    * DONE (pacman)
    
  4. Try reinstall using force = FALSE - correctly refuses to install ...

    > pacman::p_install("pacman", force = FALSE)
    Package is already on your system.
    
  5. BUT when including the reinstall in a multiple-package install, it's reinstalled:

    > pacman::p_install(c("pacman", "dplyr"), force = FALSE)
    ...
    * installing *source* package ‘pacman’
    ...
    

I consider this a bug. the vector of names of packages to be installed should be checked against presence first and then the installation action should run using the uninstalled subset.

r-cheologist avatar May 11 '19 09:05 r-cheologist

Thanks for the feedback. We'll look at this.

trinker avatar May 16 '19 11:05 trinker

Has this issue been resolved? I stopped using pacman a while ago because of this bug but would if give it another go if this is handled correctly now.

seb-mueller avatar May 12 '20 12:05 seb-mueller

Can confirm, also the documentation is outdated, as it still describes character.only being applicable to ... and not to package.

PS I'm looking for a p_load alternative that doesn't load the packages (for use in https://github.com/ropensci/targets), and I was expecting p_install to be just that, but now I need to use something like:

p_load(tidyverse)
c("biglm", "dplyr", "ggplot2", "readr", "targets", "tidyr") %>% 
  walk(p_install, force = F, character.only = T) %>% 
  suppressMessages()

burgerga avatar Jul 07 '21 12:07 burgerga