GithubHelp home page GithubHelp logo

Comments (16)

jtelleriar avatar jtelleriar commented on August 20, 2024 1

This happens also with h2o R Library :(

from conflicted.

jtelleriar avatar jtelleriar commented on August 20, 2024 1

from conflicted.

moodymudskipper avatar moodymudskipper commented on August 20, 2024 1

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)

from conflicted.

hadley avatar hadley commented on August 20, 2024 1

Just install #59 as a work around?

from conflicted.

peterlittlejohn avatar peterlittlejohn commented on August 20, 2024

This also happens with the bit64 library...

from conflicted.

nir4most avatar nir4most commented on August 20, 2024

when bit64::: is in conflict with base::: , fn_fmls fails
There's a reliance on fn_fmls() which requires a function (and doesn't like 'primitive functions')

Also just a minor edit to say that this seems intended by rlang development:
r-lib/rlang#809 (comment)

library(bit64)
debug(conflicted:::is_superset)
library(conflicted)

#when bit64::`:` is in conflict with base::`:` , fn_fmls fails 
# 
# debug: args_base <- names(fn_fmls(base_obj))
# Browse[2]> n
# Error: package or namespace load failed for ‘conflicted’:
#   .onAttach failed in attachNamespace() for 'conflicted', details:
#   call: NULL
# error: `fn` must be an R function, not a primitive function
# In addition: Warning message:
#   package ‘conflicted’ was built under R version 3.6.3 

from conflicted.

emilBeBri avatar emilBeBri commented on August 20, 2024

I also experience this issue with the bit64 package. How do you fix it?

from conflicted.

fdrennan avatar fdrennan commented on August 20, 2024

This error makes the package unusable for me almost at the start.

from conflicted.

njtierney avatar njtierney commented on August 20, 2024

I've also experienced this - does anyone have a workaround?

from conflicted.

njtierney avatar njtierney commented on August 20, 2024

Thanks, @moodymudskipper - I'll give that a go!

from conflicted.

njtierney avatar njtierney commented on August 20, 2024

For reference, this happens in this situation:


author: njtierney
date: 2021-08-18
output:
reprex::reprex_document:
session_info: true
title: dopey-nyala_reprex.R

library(greta)
#> 
#> Attaching package: 'greta'
#> The following objects are masked from 'package:stats':
#> 
#>     binomial, cov2cor, poisson
#> The following objects are masked from 'package:base':
#> 
#>     %*%, apply, backsolve, beta, chol2inv, colMeans, colSums, diag,
#>     eigen, forwardsolve, gamma, identity, rowMeans, rowSums, sweep,
#>     tapply
library(conflicted)
#> Error: package or namespace load failed for 'conflicted':
#>  .onAttach failed in attachNamespace() for 'conflicted', details:
#>   call: NULL
#>   error: `fn` must be an R function, not a primitive function

Created on 2021-08-18 by the reprex package (v2.0.0.9000)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.1.0 (2021-05-18)
#>  os       macOS Big Sur 10.16         
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_AU.UTF-8                 
#>  ctype    en_AU.UTF-8                 
#>  tz       Australia/Perth             
#>  date     2021-08-18                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date       lib source                           
#>  backports     1.2.1      2020-12-09 [1] CRAN (R 4.1.0)                   
#>  base64enc     0.1-3      2015-07-28 [1] CRAN (R 4.1.0)                   
#>  callr         3.7.0      2021-04-20 [1] CRAN (R 4.1.0)                   
#>  cli           3.0.0.9000 2021-07-05 [1] Github (r-lib/cli@82178a4)       
#>  coda          0.19-4     2020-09-30 [1] CRAN (R 4.1.0)                   
#>  codetools     0.2-18     2020-11-04 [1] CRAN (R 4.1.0)                   
#>  conflicted    1.0.4      2019-06-21 [1] CRAN (R 4.1.0)                   
#>  crayon        1.4.1      2021-02-08 [1] CRAN (R 4.1.0)                   
#>  digest        0.6.27     2020-10-24 [1] CRAN (R 4.1.0)                   
#>  ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.1.0)                   
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.1.0)                   
#>  fansi         0.5.0      2021-05-25 [1] CRAN (R 4.1.0)                   
#>  fs            1.5.0      2020-07-31 [1] CRAN (R 4.1.0)                   
#>  future        1.21.0     2020-12-10 [1] CRAN (R 4.1.0)                   
#>  globals       0.14.0     2020-11-22 [1] CRAN (R 4.1.0)                   
#>  glue          1.4.2      2020-08-27 [1] CRAN (R 4.1.0)                   
#>  greta       * 0.3.1.9012 2021-08-06 [1] local                            
#>  highr         0.9        2021-04-16 [1] CRAN (R 4.1.0)                   
#>  hms           1.1.0      2021-05-17 [1] CRAN (R 4.1.0)                   
#>  htmltools     0.5.1.1    2021-01-22 [1] CRAN (R 4.1.0)                   
#>  jsonlite      1.7.2      2020-12-09 [1] CRAN (R 4.1.0)                   
#>  knitr         1.33       2021-04-24 [1] CRAN (R 4.1.0)                   
#>  lattice       0.20-44    2021-05-02 [1] CRAN (R 4.1.0)                   
#>  lifecycle     1.0.0      2021-02-15 [1] CRAN (R 4.1.0)                   
#>  listenv       0.8.0      2019-12-05 [1] CRAN (R 4.1.0)                   
#>  magrittr      2.0.1      2020-11-17 [1] CRAN (R 4.1.0)                   
#>  Matrix        1.3-4      2021-06-01 [1] CRAN (R 4.1.0)                   
#>  parallelly    1.26.1     2021-06-30 [1] CRAN (R 4.1.0)                   
#>  pillar        1.6.2      2021-07-29 [1] CRAN (R 4.1.0)                   
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.1.0)                   
#>  png           0.1-7      2013-12-03 [1] CRAN (R 4.1.0)                   
#>  prettyunits   1.1.1      2020-01-24 [1] CRAN (R 4.1.0)                   
#>  processx      3.5.2      2021-04-30 [1] CRAN (R 4.1.0)                   
#>  progress      1.2.2      2019-05-16 [1] CRAN (R 4.1.0)                   
#>  ps            1.6.0      2021-02-28 [1] CRAN (R 4.1.0)                   
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.1.0)                   
#>  R6            2.5.0      2020-10-28 [1] CRAN (R 4.1.0)                   
#>  Rcpp          1.0.7      2021-07-07 [1] CRAN (R 4.1.0)                   
#>  reprex        2.0.0.9000 2021-07-02 [1] Github (tidyverse/reprex@5cf02b4)
#>  reticulate    1.20       2021-05-03 [1] CRAN (R 4.1.0)                   
#>  rlang         0.4.11     2021-04-30 [1] CRAN (R 4.1.0)                   
#>  rmarkdown     2.9        2021-06-15 [1] CRAN (R 4.1.0)                   
#>  rstudioapi    0.13       2020-11-12 [1] CRAN (R 4.1.0)                   
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.1.0)                   
#>  stringi       1.7.3      2021-07-16 [1] CRAN (R 4.1.0)                   
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 4.1.0)                   
#>  styler        1.4.1      2021-03-30 [1] CRAN (R 4.1.0)                   
#>  tensorflow    2.5.0      2021-06-10 [1] CRAN (R 4.1.0)                   
#>  tfruns        1.5.0      2021-02-26 [1] CRAN (R 4.1.0)                   
#>  tibble        3.1.3      2021-07-23 [1] CRAN (R 4.1.0)                   
#>  utf8          1.2.2      2021-07-24 [1] CRAN (R 4.1.0)                   
#>  vctrs         0.3.8      2021-04-29 [1] CRAN (R 4.1.0)                   
#>  whisker       0.4        2019-08-28 [1] CRAN (R 4.1.0)                   
#>  withr         2.4.2      2021-04-18 [1] CRAN (R 4.1.0)                   
#>  xfun          0.24       2021-06-15 [1] CRAN (R 4.1.0)                   
#>  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.1.0)                   
#> 
#> [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library

vs the opposite order


author: njtierney
date: 2021-08-18
output:
reprex::reprex_document:
session_info: true
title: next-esok_reprex.R

library(conflicted)
library(greta)
#> Error: `fn` must be an R function, not a primitive function

Created on 2021-08-18 by the reprex package (v2.0.0.9000)

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.1.0 (2021-05-18)
#>  os       macOS Big Sur 10.16         
#>  system   x86_64, darwin17.0          
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_AU.UTF-8                 
#>  ctype    en_AU.UTF-8                 
#>  tz       Australia/Perth             
#>  date     2021-08-18                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date       lib source                           
#>  backports     1.2.1      2020-12-09 [1] CRAN (R 4.1.0)                   
#>  base64enc     0.1-3      2015-07-28 [1] CRAN (R 4.1.0)                   
#>  cachem        1.0.5      2021-05-15 [1] CRAN (R 4.1.0)                   
#>  callr         3.7.0      2021-04-20 [1] CRAN (R 4.1.0)                   
#>  cli           3.0.0.9000 2021-07-05 [1] Github (r-lib/cli@82178a4)       
#>  coda          0.19-4     2020-09-30 [1] CRAN (R 4.1.0)                   
#>  codetools     0.2-18     2020-11-04 [1] CRAN (R 4.1.0)                   
#>  conflicted  * 1.0.4      2019-06-21 [1] CRAN (R 4.1.0)                   
#>  crayon        1.4.1      2021-02-08 [1] CRAN (R 4.1.0)                   
#>  digest        0.6.27     2020-10-24 [1] CRAN (R 4.1.0)                   
#>  ellipsis      0.3.2      2021-04-29 [1] CRAN (R 4.1.0)                   
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.1.0)                   
#>  fansi         0.5.0      2021-05-25 [1] CRAN (R 4.1.0)                   
#>  fastmap       1.1.0      2021-01-25 [1] CRAN (R 4.1.0)                   
#>  fs            1.5.0      2020-07-31 [1] CRAN (R 4.1.0)                   
#>  future        1.21.0     2020-12-10 [1] CRAN (R 4.1.0)                   
#>  globals       0.14.0     2020-11-22 [1] CRAN (R 4.1.0)                   
#>  glue          1.4.2      2020-08-27 [1] CRAN (R 4.1.0)                   
#>  greta       * 0.3.1.9012 2021-08-06 [1] local                            
#>  highr         0.9        2021-04-16 [1] CRAN (R 4.1.0)                   
#>  hms           1.1.0      2021-05-17 [1] CRAN (R 4.1.0)                   
#>  htmltools     0.5.1.1    2021-01-22 [1] CRAN (R 4.1.0)                   
#>  jsonlite      1.7.2      2020-12-09 [1] CRAN (R 4.1.0)                   
#>  knitr         1.33       2021-04-24 [1] CRAN (R 4.1.0)                   
#>  lattice       0.20-44    2021-05-02 [1] CRAN (R 4.1.0)                   
#>  lifecycle     1.0.0      2021-02-15 [1] CRAN (R 4.1.0)                   
#>  listenv       0.8.0      2019-12-05 [1] CRAN (R 4.1.0)                   
#>  magrittr      2.0.1      2020-11-17 [1] CRAN (R 4.1.0)                   
#>  Matrix        1.3-4      2021-06-01 [1] CRAN (R 4.1.0)                   
#>  parallelly    1.26.1     2021-06-30 [1] CRAN (R 4.1.0)                   
#>  pillar        1.6.2      2021-07-29 [1] CRAN (R 4.1.0)                   
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.1.0)                   
#>  png           0.1-7      2013-12-03 [1] CRAN (R 4.1.0)                   
#>  prettyunits   1.1.1      2020-01-24 [1] CRAN (R 4.1.0)                   
#>  processx      3.5.2      2021-04-30 [1] CRAN (R 4.1.0)                   
#>  progress      1.2.2      2019-05-16 [1] CRAN (R 4.1.0)                   
#>  ps            1.6.0      2021-02-28 [1] CRAN (R 4.1.0)                   
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.1.0)                   
#>  R6            2.5.0      2020-10-28 [1] CRAN (R 4.1.0)                   
#>  Rcpp          1.0.7      2021-07-07 [1] CRAN (R 4.1.0)                   
#>  reprex        2.0.0.9000 2021-07-02 [1] Github (tidyverse/reprex@5cf02b4)
#>  reticulate    1.20       2021-05-03 [1] CRAN (R 4.1.0)                   
#>  rlang         0.4.11     2021-04-30 [1] CRAN (R 4.1.0)                   
#>  rmarkdown     2.9        2021-06-15 [1] CRAN (R 4.1.0)                   
#>  rstudioapi    0.13       2020-11-12 [1] CRAN (R 4.1.0)                   
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.1.0)                   
#>  stringi       1.7.3      2021-07-16 [1] CRAN (R 4.1.0)                   
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 4.1.0)                   
#>  styler        1.4.1      2021-03-30 [1] CRAN (R 4.1.0)                   
#>  tensorflow    2.5.0      2021-06-10 [1] CRAN (R 4.1.0)                   
#>  tfruns        1.5.0      2021-02-26 [1] CRAN (R 4.1.0)                   
#>  tibble        3.1.3      2021-07-23 [1] CRAN (R 4.1.0)                   
#>  utf8          1.2.2      2021-07-24 [1] CRAN (R 4.1.0)                   
#>  vctrs         0.3.8      2021-04-29 [1] CRAN (R 4.1.0)                   
#>  whisker       0.4        2019-08-28 [1] CRAN (R 4.1.0)                   
#>  withr         2.4.2      2021-04-18 [1] CRAN (R 4.1.0)                   
#>  xfun          0.24       2021-06-15 [1] CRAN (R 4.1.0)                   
#>  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.1.0)                   
#> 
#> [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library

from conflicted.

njtierney avatar njtierney commented on August 20, 2024

@moodymudskipper

Unfortunately this doesn't prevent my error :( - I tried having a local .Rprofile for my project with the code:

This is really unfortunate, as I need to use greta in my work - and the conflicted package is now a key part of my workflow, and I now need to remove conflicted from my work, which means developing a workaround - which is unfortunately not trivial.

from conflicted.

njtierney avatar njtierney commented on August 20, 2024

I got this to work by adding warn.conflicts = FALSE like so:

library(conflicted)
library(greta, warn.conflicts = FALSE)

from conflicted.

njtierney avatar njtierney commented on August 20, 2024

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)

from conflicted.

njtierney avatar njtierney commented on August 20, 2024

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 conflicted with some projects if we use certain packages.

This introduces a pretty huge amount of friction, as we came to really depend on conflicted, and to switch back to life pre-conflicted is very challenging.

from conflicted.

njtierney avatar njtierney commented on August 20, 2024

Thanks, Hadley! :)

from conflicted.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.