rtidyversesparklyr

Is there a way I can use the `exclude` argument in `library()` on a sub-package?


I keep on running into this issue, where purrr::invoke is masking sparklyr::invoke. It causes a lot of {sparklyr} functionalities not to work.

I can fix it with invoke <- sparklyr::invoke, but it seems like a hack. Is there a way to use the exclude argument in library() instead?

I tried both of these, and neither worked.

library(tidyverse, exclude = "invoke")
#> Warning in rm(list = exclude, envir = env): object 'invoke' not found
invoke
#> function (.f, .x = NULL, ..., .env = NULL) 
#> {
#>     lifecycle::deprecate_soft("1.0.0", "invoke()", "exec()")
#>     .env <- .env %||% parent.frame()
#>     args <- c(as.list(.x), list(...))
#>     do.call(.f, args, envir = .env)
#> }
#> <bytecode: 0x000001a77b6339f0>
#> <environment: namespace:purrr>
library(tidyverse, exclude = "purrr::invoke")
#> Warning in rm(list = exclude, envir = env): object 'purrr::invoke' not found
invoke
#> function (.f, .x = NULL, ..., .env = NULL) 
#> {
#>     lifecycle::deprecate_soft("1.0.0", "invoke()", "exec()")
#>     .env <- .env %||% parent.frame()
#>     args <- c(as.list(.x), list(...))
#>     do.call(.f, args, envir = .env)
#> }
#> <bytecode: 0x000001c03be31e78>
#> <environment: namespace:purrr>

Solution

  • You can use the conflicted package to handle this. Either of these will give you sparklyr::invoke when you ask for invoke:

    library(tidyverse)
    library(sparklyr)
    conflicted::conflict_prefer("invoke", "sparklyr")
    

    or loading in the other order:

    library(sparklyr)
    library(tidyverse)
    conflicted::conflict_prefer("invoke", "sparklyr")