Skip to content
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 a setting to specify default repositories #5547

Merged
merged 6 commits into from
Dec 2, 2024
Merged

Conversation

jmcphers
Copy link
Collaborator

@jmcphers jmcphers commented Nov 27, 2024

This change adds a new setting that allows end users to select the default repository used in R sessions. Prior to the change, we always used cran.rstudio.com if no other repository was set; this remains the default, but now there are several other choices:

image

For compatibility with shared RStudio configurations, the auto setting also checks for a repos.conf file in well-known XDG locations. You can read more about the expected format of this file here: https://solutions.posit.co/envs-pkgs/rsw_defaults/#repos.conf

Addresses #5509

Note

This change depends on a change from ark (posit-dev/ark#645) and should not be merged until that change is.

QA Notes

  • These repositories are defaults and shouldn't override anything you've already set in e.g. .Rprofile or Rprofile.site.
  • It is not strictly necessary to restart Positron to apply changes to the new option; you only need to shut down your R session (not restart it) and create a new one. We say "restart Positron" because it's easier for people to understand.
  • The XDG locations searched include both Positron and RStudio directories. On macOS, for example, repos.conf can be placed in ~/Library/Preferences/positron/repos.conf.

@jmcphers jmcphers requested a review from jennybc November 27, 2024 19:36
Copy link
Member

@jennybc jennybc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving two comments this PR inspired. About to try this out locally.

Comment on lines +46 to +51
const env = <Record<string, string>>{
'RUST_BACKTRACE': '1',
'RUST_LOG': logLevelForeign + ',ark=' + logLevel,
'R_HOME': rHomePath,
...userEnv
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor observation: we are using a little interface for env vars elsewhere in positron-r (but I don't think this matters that much and I see this code pre-existed, it's just moving in this PR):

export interface EnvVar {
[key: string]: string;
}

export async function prepCliEnvVars(session?: RSession): Promise<EnvVar> {

export async function getEnvVars(envVars: string[], session?: RSession): Promise<EnvVar[]> {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good observation! Indeed I didn't touch this (just moved it to keep the file from becoming too unwieldy) but that'd be an improvement.

"r.configuration.taskHyperlinks.description": "Turn on experimental support for hyperlinks in package development tasks",
"r.configuration.defaultRepositories.description": "The default repositories to use for R package installation, if no repository is otherwise specified in R startup scripts (restart Positron to apply).\n\nThe default repositories will be set as the `repos` option in R.",
"r.configuration.defaultRepositories.auto.description": "Automatically choose a default repository, or use a repos.conf file if it exists.",
"r.configuration.defaultRepositories.rstudio.description": "Use the RStudio CRAN mirror (cran.rstudio.com)",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking this chance to have a side discussion:

In my .Rprofile, I have

...
repos = c(
    P3M = "https://p3m.dev/cran/latest",
    CRAN = "https://cloud.r-project.org"
)
...

In terms of what we feature, is there a reason to push cran.rstudio.com over cloud.r-project.org? I guess I've implicitly preferred the latter from some super vague reasons around rstudio->posit rebrand and avoiding overt branding.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we necessarily want to push cran.rstudio.com (Posit also sponsors cloud.r-project.org), I just used it to match ark's existing behavior. Might be worth providing a cloud.r-project.org option too, let's see what folks say.

jennybc
jennybc previously approved these changes Dec 2, 2024
Copy link
Member

@jennybc jennybc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I played around with this, with an appropriate ark version, and all seems well. I can switch between the different enum values and I can also use a repos.conf file with "auto".

@jmcphers jmcphers merged commit 58d2069 into main Dec 2, 2024
5 checks passed
@jmcphers jmcphers deleted the feature/default-repos branch December 2, 2024 22:49
@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants