r-lib / rlang

Low-level API for programming with R
https://rlang.r-lib.org
Other
500 stars 137 forks source link

check_installed: error on just-uninstalled package (dirty R session) #1561

Closed aronatkins closed 1 year ago

aronatkins commented 1 year ago

Using rlang-1.0.6:

install.packages("shiny")
requireNamespace("shiny")
remove.packages("shiny")
rlang::check_installed("shiny", version = "0.0.1", reason = "to be shiny")
#> 
#>   There is a binary version available but the source version is later:
#>       binary source needs_compilation
#> shiny  1.6.0  1.7.4             FALSE
#> installing the source package 'shiny'
#> Loading required namespace: shiny
#> Removing package from '/Library/Frameworks/R.framework/Versions/3.6/Resources/library'
#> (as 'lib' is unspecified)
#> Error in utils::packageVersion(pkg): there is no package called 'shiny'

The utils::packageVersion error goes away if the R session is restarted after removing shiny.

Created on 2023-02-13 with reprex v2.0.2