Skip to content

fix: say how to set a CRAN mirror when jgd cannot be offered - #1993

Merged
renkun-ken merged 2 commits into
REditorSupport:mainfrom
mvanhorn:fix/1929-jgd-cran-mirror-error
Nov 29, 2026
Merged

renkun-ken merged 2 commits into
REditorSupport:mainfrom
mvanhorn:fix/1929-jgd-cran-mirror-error

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Motivation

When jgd is missing and the R session has no usable package repository configured (for example, when CRAN is still set to the "@CRAN@" placeholder), vscode-R skips the installation prompt and falls back to the standard plot viewer. The setup error only states that no usable package repository is configured, without explaining that this prevents the installation prompt from appearing or how to configure a CRAN mirror.

tool_library_plan() in R/tool-library.R rejects non-character repos values and filters out NA, empty strings, and "@CRAN@", stopping before an installation plan can be built when no repositories remain. Both stop() calls previously returned generic messages that did not mention the "@CRAN@" placeholder, the suppressed prompt, or the options(repos = ...) setting needed to resolve the issue.

Summary

In R/tool-library.R, tool_library_plan() now tells users to set options(repos = c(CRAN = "https://cloud.r-project.org")) and restart the R terminal when repos is not a character vector. When no usable repositories remain after filtering, the error message now explains that getOption("repos") is empty or still contains only "@CRAN@", notes that the installation prompt is not shown without a downloadable repository, and provides the same CRAN mirror configuration and restart guidance.

In R/tests/tool-library.R, a test case is added to check that calling tool_library_plan() with repos = c(CRAN = "@CRAN@") raises an error mentioning both "@CRAN@" and "https://cloud.r-project.org".

Testing

Ran pnpm run format:check locally on macOS for the vscode-R change; it passed. pnpm run format:check passed across all 233 matched files. pnpm run format:r:check ran and reported no formatting issues. pnpm run lint:r ran and reported no lint issues. lintr::lint_dir("./R") ran and reported no lint findings. lintr::lint_package("sess") ran and reported no lint findings. pnpm run lint ran and reported no lint issues. Ran pnpm run format:check in a Linux container (localhost/osc-linux-node:22) for the vscode-R change; it passed.

The tests in R/tests/tool-library.R fail without the fix in the vscode-R change (checked by reverting the source changes). The changed test R/tests/tool-library.R did not run here: no test runner for it was available.

Closes #1929

In `R/tool-library.R`, `tool_library_plan()` now tells users to set
`options(repos = c(CRAN = "https://cloud.r-project.org"))` and restart
the R terminal when `repos` is not a character vector. When no usable
repositories remain after filtering, the error message now explains that
`getOption("repos")` is empty or still contains only `"@cran@"`, notes
that the installation prompt is not shown without a downloadable
repository, and provides the same CRAN mirror configuration and restart
guidance. In `R/tests/tool-library.R`, a test case is added to check
that calling `tool_library_plan()` with `repos = c(CRAN = "@cran@")`
raises an error mentioning both `"@cran@"` and
`"https://cloud.r-project.org"`.

Fixes REditorSupport#1929

@renkun-ken renkun-ken left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I ran R/tests/tool-library.R and R/tests/tool-consent.R with R 4.6.1. Both passed.

Comment thread R/tool-library.R Resolved
Setting the option at the console does not survive the R terminal
restart, so jgd setup sees @cran@ again. Both errors now say to add the
line to the .Rprofile the project loads, and the test checks for it.

@renkun-ken renkun-ken left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Both error messages now tell users to save the mirror in the .Rprofile their project loads before restarting. I verified that a fresh R process using vscode-R’s startup profile picked up the mirror from the project .Rprofile. The regression test checks for that guidance, and the managed tool library and consent tests both passed locally on R 4.6.1. This resolves my earlier finding.

@renkun-ken
renkun-ken merged commit 656d02b into REditorSupport:main Nov 29, 2026
11 checks passed
@mvanhorn

Copy link
Copy Markdown
Contributor Author

@renkun-ken thanks for merging this. The jgd setup error now tells people how to set a CRAN mirror in their .Rprofile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: v3.4.0 does not offer to install "jgd"

2 participants