New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Error: fn must be an R function, not a primitive function" after library call
#48
Comments
|
This happens also with |
|
This also happens with the |
|
when bit64:: Also just a minor edit to say that this seems intended by rlang development: |
|
I also experience this issue with the bit64 package. How do you fix it? |
|
This error makes the package unusable for me almost at the start. |
|
I've also experienced this - does anyone have a workaround? |
|
You could use another approach:
https://developer.r-project.org/Blog/public/2019/03/19/managing-search-path-conflicts/
|
|
If you put the first call below in your RProfile it seems to work ok : setHook(
packageEvent("conflicted", "attach"),
function(...) {
invisible(suppressMessages(trace(conflicted:::is_superset, quote(
if(is.primitive(get(fun))) {
# hacking the existing exception for "lag"
pkg <- "dplyr"
fun <- "lag"
}
), print = FALSE)))
}
)
library(conflicted)
#> Warning: package 'conflicted' was built under R version 4.0.5
library(inops)
x <- 1:5
x < 3 <- 0
#> Error: [conflicted] `<<-` found in 2 packages.
#> Declare a preference with `conflict_prefer()`:
#> * conflict_prefer("<<-", "inops")
#> * conflict_prefer("<<-", "base")
conflict_prefer("<<-", "base")
#> [conflicted] Will prefer base::`<<-` over any other package
x < 3 <- 0
#> Error in x < 3 <- 0: incorrect number of arguments to "<<-"
conflict_prefer("<<-", "inops")
#> [conflicted] Removing existing preference
#> [conflicted] Will prefer inops::`<<-` over any other package
x < 3 <- 0
x
#> [1] 0 0 3 4 5
# works with other packages mentionned in thread
suppressPackageStartupMessages({
library(h2o)
library(bit64)
})
#> Warning: package 'h2o' was built under R version 4.0.5
#> Warning: package 'bit64' was built under R version 4.0.3
#> Warning: package 'bit' was built under R version 4.0.3
`%*%`
#> Error: [conflicted] `%*%` found in 2 packages.
#> Declare a preference with `conflict_prefer()`:
#> * conflict_prefer("%*%", "h2o")
#> * conflict_prefer("%*%", "base")
`:`
#> Error: [conflicted] `:` found in 2 packages.
#> Declare a preference with `conflict_prefer()`:
#> * conflict_prefer(":", "bit64")
#> * conflict_prefer(":", "base")Created on 2021-08-13 by the reprex package (v0.3.0) |
|
Thanks, @moodymudskipper - I'll give that a go! |
|
For reference, this happens in this situation: author: njtierney
|
|
Unfortunately this doesn't prevent my error :( - I tried having a local This is really unfortunate, as I need to use |
|
I got this to work by adding library(conflicted)
library(greta, warn.conflicts = FALSE) |
|
Ah, for this to work, I needed the following in my local Rprofile: setHook(
packageEvent("conflicted", "attach"),
function(...) {
invisible(suppressMessages(trace(conflicted:::is_superset, quote(
if(is.primitive(get(fun))) {
# hacking the existing exception for "lag"
pkg <- "dplyr"
fun <- "lag"
}
), print = FALSE)))
}
)
library(conflicted)
|
|
Hi there @hadley / @batpigandme Sorry to bother you here, but I was just wondering if you have a recommended workaround for this or plans to fix? It currently means we can't really use This introduces a pretty huge amount of friction, as we came to really depend on |
|
Just install #59 as a work around? |
|
Thanks, Hadley! :) |
This happens when attaching one of my packages :
The package can be attached without problem if conflicted is not attached.
It appears to come from the fact that the package overrides a primitive (namely
<<-).library(conflicted) triggers
conflicted:::.onAttach(), which callsconflicted:::conflicts_register(), which callsconflicted:::is_superset()andrlang::fn_fmls()is called, and chokes on primitives because they have no formals.If I call
library()twice then I have no error and can use the package, including<<-:library(conflicted)will be the one failing if it's called second :The text was updated successfully, but these errors were encountered: