vscode-R icon indicating copy to clipboard operation
vscode-R copied to clipboard

"conflicted" is evoked for each prompt

Open heavywatal opened this issue 2 years ago • 1 comments

Describe the bug When there is a conflict on setdiff(), conflicted complains about it every time a new prompt > shows up even when the function was not called by a user. I guess the cause is the use of setdiff() in vscode-R given that this issue does not happen in a session without source("~/.vscode-R/init.R"). It does not happen with R.app, RStudio, or bare /usr/local/bin/R.

setdiff() was the trigger this time, but potentially any conflict in functions used by vscode-R can cause the similar issue.

To Reproduce

  1. Setup vscode-R and source("~/.vscode-R/init.R").
  2. Setup some conflicts: install conflicted, tidyverse, and BiocGenerics (or any packages that export setdiff()).
  3. library(conflicted)
  4. library(tidyverse)
  5. library(BiocGenerics)
  6. Do something: ls(), 1 + 1, or whatever.

Can you fix this issue by yourself? (We appreciate the help)

No. I guess adding an explicit namespace base:: to setdiff() in R/session/vsc.R can be a quick fix for this issue.

(If yes,) can we assist you with anything?

(If applicable) Please attach setting.json

    "r.helpPanel.clickCodeExamples": {
      "Click": "Ignore",
      "Shift+Click": "Copy"
    },
    "r.plot.useHttpgd": false,
    "r.rmarkdown.enableCodeLens": false,
    "r.session.viewers.viewColumn": {
      "plot": "Disable"
    },
    "r.sessionWatcher": true,

Expected behavior vscode-R does not stimulate "conflicted" package even when there are some conflicts.

Screenshots

> library(BiocGenerics)
[conflicted] setdiff found in 3 packages.
Either pick the one you want with `::`:
• BiocGenerics::setdiff
• lubridate::setdiff
• base::setdiff
Or declare a preference with `conflicts_prefer()`:
• `conflicts_prefer(BiocGenerics::setdiff)`
• `conflicts_prefer(lubridate::setdiff)`
• `conflicts_prefer(base::setdiff)`> 1 + 1
[1] 2
[conflicted] setdiff found in 3 packages.
Either pick the one you want with `::`:
• BiocGenerics::setdiff
• lubridate::setdiff
• base::setdiff
Or declare a preference with `conflicts_prefer()`:
• `conflicts_prefer(BiocGenerics::setdiff)`
• `conflicts_prefer(lubridate::setdiff)`
• `conflicts_prefer(base::setdiff)`>

Environment (please complete the following information):

  • OS: macOS
  • VSCode Version: 1.82.2
  • R Version: 4.3.1
  • vscode-R version: 2.8.1

Additional context

setdiff from BiocGenerics may not be conflicting in the first place (r-lib/conflicted#8).

heavywatal avatar Sep 19 '23 16:09 heavywatal

namespacing seems a reasonable fix

ElianHugh avatar Mar 01 '24 13:03 ElianHugh