-
Notifications
You must be signed in to change notification settings - Fork 14
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
Using conflicts_prefer()
et al. in .Rprofile
no longer works
#91
Comments
I am able to reproduce what OP reports in a terminal:
but not in RStudio:
|
Here's a minimal reprex: writeLines(con = ".Rprofile", c(
"library(dplyr)",
"conflicted::conflicts_prefer(dplyr::filter)"
))
environment(filter)
#> <environment: namespace:stats>
search()
#> [1] ".GlobalEnv" "package:stats" "package:graphics"
#> [4] "package:grDevices" "package:utils" "package:datasets"
#> [7] "package:methods" "Autoloads" "tools:callr"
#> [10] "package:base" Created on 2023-10-01 with reprex v2.0.2 I thought this might be because this code is run before the stats package is attached, and thus conflicted doesn't find any conflicts. But explicitly loading stats doesn't change anything: writeLines(con = ".Rprofile", c(
"library(stats)",
"library(dplyr)",
"conflicted::conflicts_prefer(dplyr::filter)"
))
environment(filter)
#> <environment: namespace:stats>
search()
#> [1] ".GlobalEnv" "package:stats" "package:graphics"
#> [4] "package:grDevices" "package:utils" "package:datasets"
#> [7] "package:methods" "Autoloads" "tools:callr"
#> [10] "package:base" Created on 2023-10-01 with reprex v2.0.2 |
Oh that's because my reprex isn't actually working; dplyr never gets loaded. |
Ok, better reprex which illustrates that my initial guess at the problem was correct: dir <- tempfile()
dir.create(dir)
writeLines(con = file.path(dir, ".Rprofile"), c(
"library(dplyr)",
"conflicted::conflicts_prefer(dplyr::filter)"
))
setwd(dir)
callr::r(user_profile = TRUE, function() {
list(env = environment(filter), search = search())
})
#> $env
#> <environment: namespace:stats>
#>
#> $search
#> [1] ".GlobalEnv" "package:stats" "package:graphics"
#> [4] "package:grDevices" "package:utils" "package:datasets"
#> [7] ".conflicts" "package:dplyr" "package:methods"
#> [10] "Autoloads" "tools:callr" "package:base" Created on 2023-10-01 with reprex v2.0.2 dir <- tempfile()
dir.create(dir)
writeLines(con = file.path(dir, ".Rprofile"), c(
"library(stats)",
"library(dplyr)",
"conflicted::conflicts_prefer(dplyr::filter)"
))
setwd(dir)
callr::r(user_profile = TRUE, function() {
list(env = environment(filter), search = search())
})
#> $env
#> <environment: namespace:dplyr>
#>
#> $search
#> [1] ".GlobalEnv" "package:graphics" "package:grDevices"
#> [4] "package:utils" "package:datasets" ".conflicts"
#> [7] "package:dplyr" "package:stats" "package:methods"
#> [10] "Autoloads" "tools:callr" "package:base" Created on 2023-10-01 with reprex v2.0.2 |
If |
Using
conflicts_prefer()
in an.Rprofile
file no longer works, though from the console output it appears to.I'm sure that it used to work before. Since the last release of
{conflicted}
was in February and I'm pretty sure it has worked after that for some time, maybe a change in R 4.3.0, or even 4.3.1, is causing this?Steps to reproduce:
In an empty folder, create an
.Rprofile
file with the following contents:Start R in this folder. Output:
But
dplyr::filter
is not in fact preferred:Running the call to
conflicts_prefer()
again, on the command line or by sourcing.Rprofile
, works:The same happens when using
conflict_prefer()
instead.Edit:
sessionInfo()
after starting RThe text was updated successfully, but these errors were encountered: