-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add attribute to repos
, for renv users
#502
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,20 +29,19 @@ options(device = function() { | |
# Set cran mirror | ||
repos <- getOption("repos") | ||
rstudio_cran <- "https://cran.rstudio.com/" | ||
|
||
if (is.null(repos) || !is.character(repos)) { | ||
options(repos = c(CRAN = rstudio_cran)) | ||
repos <- c(CRAN = rstudio_cran) | ||
} else { | ||
if ("CRAN" %in% names(repos)) { | ||
if (identical(repos[["CRAN"]], "@CRAN@")) { | ||
repos[["CRAN"]] <- rstudio_cran | ||
options(repos = repos) | ||
} | ||
} else { | ||
repos <- c(CRAN = rstudio_cran, repos) | ||
options(repos = repos) | ||
} | ||
} | ||
attr(repos, "Positron") <- TRUE | ||
juliasilge marked this conversation as resolved.
Show resolved
Hide resolved
|
||
options(repos = repos) | ||
|
||
# Show Plumber apps in the viewer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have one other larger worry about this in general. None of this is going to kick in if the user is using a version of R installed with Rig. That's because Rig sets That means that every time you load up a rig installed version of R, it will always have https://github.com/r-lib/rig/blob/140115c9b565167670cfc6f303e6c968c563db98/src/windows.rs#L342 That means we would never add the I can confirm this by loading up my non-rig R-devel version in a plain terminal:
vs a rig installed R 4.4
Now, this may be ok for Positron because on Linux you can see in the above link that rig sets up PPM as the The bigger issue would be for renv itself, because it means that renv will never detect a "default" case and can't set the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not think we should let this stop us from moving on this PR, but @kevinushey may want to take a closer look at this weird rig + renv intersection issue, especially the inability to set a user customized There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @juliasilge if you do as I suggest above and only conditionally set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not a rig user 😆 so I did not notice this. I will add a note for renv when I say this new attribute is available. |
||
options(plumber.docs.callback = function(url) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not unconditionally set this. IIUC, we should only set this if we detect the "default" repos behavior, i.e. if we see
"@CRAN@"
as therepos[["CRAN"]]
valueThat is what RStudio does
https://github.com/rstudio/rstudio/blob/078e21116b0e34aff92addf961699017adb62fc5/src/cpp/r/R/Tools.R#L682-L712
I think that means you only set the attribute in the
if (identical(repos[["CRAN"]], "@CRAN@")) {
branchIn theory this allows a user to set their own
repos
in their.Rprofile
, and in that case we are not supposed to mark that with a"Positron"
attribute, as that did not come from us. In practice that might not work, because I think this code might get run before we source a user's.Rprofile
on their behalf, but that would be another bug to fix separately, I think.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I misunderstood before how this was being used! Thanks 👍