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

options(cli.hyperlink = TRUE) is propagating to subprocesses #3053

Closed
DavisVaughan opened this issue May 7, 2024 · 4 comments
Closed

options(cli.hyperlink = TRUE) is propagating to subprocesses #3053

DavisVaughan opened this issue May 7, 2024 · 4 comments
Labels
bug Something isn't working lang: r

Comments

@DavisVaughan
Copy link
Contributor

  • Clone tidymodels/recipes
  • Run devtools::document()

You should see:

Screenshot 2024-05-07 at 4 47 53 PM

Note that if you print out the code in selections.Rmd, you eventually hit this expected error

Screenshot 2024-05-07 at 4 36 39 PM

The problem is that hyperlink. Due to the fact that we set cli.hyperlink = TRUE, subprocesses like the one document() runs in also sets it to TRUE, even though it is not supported there, and cli tries to generate hyperlink related ansi characters that xml2 doesn't support.

# Tell cli that Positron's console supports colors.
# Requires cli >=3.6.1.9000 (https://github.com/r-lib/cli/pull/625)
options(cli.default_num_colors = 256L)
# Tell cli that Positron's console supports dynamic updates
# TODO: This would be better as `cli.default_dynamic`, but that doesn't exist
# yet.
options(cli.dynamic = TRUE)
# Tell cli what kind of hyperlinks are supported in the Positron console.
# TODO: These would be better as `cli.default_*`, but those don't exist yet.
options(cli.hyperlink = TRUE)
options(cli.hyperlink_run = TRUE)
options(cli.hyperlink_help = TRUE)
options(cli.hyperlink_vignette = TRUE)

Now, we actually are handling the color correctly here. i.e. we set cli.default_num_colors rather than cli.num_colors, and the "default" there means that it won't apply in the subprocess. This was set and fixed in #1106, where we had this exact issue, but with cli colors rather than hyperlinks.

To do this correctly, we need cli to give us the following options:

  • cli.default_hyperlink
  • cli.default_hyperlink_run
  • cli.default_hyperlink_help
  • cli.default_hyperlink_vignette
  • cli.default_dynamic

That would allow Positron to set all of these, and then subprocesses will not inherit them.

@DavisVaughan DavisVaughan added the bug Something isn't working label May 7, 2024
@DavisVaughan
Copy link
Contributor Author

DavisVaughan commented May 7, 2024

Ooooh I just learned that the roxygen2:::local_reproducible_output() (different from testthat's one) does not set cli.hyperlink = FALSE, unlike the testthat one, and I think it should. That would be an easier stopgap to fix this, I think, with the endgoal of still wanting the "default" options in cli
https://github.com/r-lib/roxygen2/blob/2357de6fe50df352f286a4ec77f65e00e582fa21/R/rd-include-rmd.R#L52
https://github.com/r-lib/roxygen2/blob/2357de6fe50df352f286a4ec77f65e00e582fa21/R/rd-eval.R#L15-L23

I have opened r-lib/roxygen2#1620 and will probably do a PR and will report back

@DavisVaughan
Copy link
Contributor Author

DavisVaughan commented May 8, 2024

r-lib/roxygen2#1621 is merged so this works now and allows us to delay needing cli.default_* a little longer

But we should probably document that you need dev roxygen2 now for the best experience

@juliasilge
Copy link
Contributor

In Positron 2024.05.0 (Universal) build 1176, this is now fixed when I use the development version of roxygen2:

Image

I added roxygen2 here: https://github.com/posit-dev/positron-beta/wiki#r-prerequisites

I'll follow up with a PR to the internal wiki repo.

@juliasilge
Copy link
Contributor

This is now updated here as well: https://connect.posit.it/positron-wiki/getting-started.html#r-prerequisites

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working lang: r
Projects
None yet
Development

No branches or pull requests

2 participants