Quarto render throws error when using the conflicted package

Hi all, I tried to create a reprex:

### Load packages

```{r}
#| label: setup
#| include: false

###### TIDYVERSE ######
# Data manipulation
library("dplyr")

# Analysis of cell-cell communication
library("CellChat")

# Make every conflict trigger an error
library("conflicted")
```

```{r}
# Load dplyr
library(dplyr)

# Create two data frames
df1 <- data.frame(
  id = c(1, 2, 3, 4),
  name = c("Alice", "Bob", "Charlie", "David")
)

df2 <- data.frame(
  id = c(3, 4, 5),
  name = c("Charlie", "David", "Eve")
)

# Find rows in df1 that are not in df2
diff_df <- dplyr::setdiff(df1, df2)

# Print the result
print(diff_df)
```

This is the error I am getting:

quarto render Analysis/repro.qmd 
here() starts at /Users/.../Documents/University Project/analysis


processing file: repro.qmd
  |.....................                               |  40% [setup]          

Error:
! [conflicted] setdiff found in 3 packages.
Either pick the one you want with `::`:
• BiocGenerics::setdiff
• dplyr::setdiff
• base::setdiff
Or declare a preference with `conflicts_prefer()`:
• `conflicts_prefer(BiocGenerics::setdiff)`
• `conflicts_prefer(dplyr::setdiff)`
• `conflicts_prefer(base::setdiff)`

I'm not entirely sure how reproducible this code is, as it appears to depend on which packages are loaded, and I haven't found a way to load only a specific subset of them. That said, the code runs perfectly when executed manually. I would appreciate any suggestions or insights on how to resolve this issue. Thank you!

At a guess,you have all three packages loaded, possibly in different rsections and R does not know which one to use. You are being asked to specify which one to use.

Do you intend to use one specific setdiff? If so this looks like the way to go. Put it at the start of the document probably just below the YAML.

conflicts_prefer(dplyr::setdiff)

If you are using more than one then each time specify which one in the r section

dplyr::setdiff