Skip to content

Set options lazily and conditionally#1123

Open
lionel- wants to merge 5 commits intomainfrom
feature/shiny-browser-option
Open

Set options lazily and conditionally#1123
lionel- wants to merge 5 commits intomainfrom
feature/shiny-browser-option

Conversation

@lionel-
Copy link
Copy Markdown
Contributor

@lionel- lionel- commented Mar 21, 2026

Addresses posit-dev/positron#8450

Set our options after the user R profiles have been sourced, and only if the options haven't been set by the user already. We detect user overrides in one of two ways:

  • If R sets the option to a non-null value by default, we require the user to wrap the option in AsIs, which we take as a sign it was overridden in the Rprofile.

  • For all other options, if we see a non-null value it means it was overridden.

I've taken the opportunity to consolidate all options settings in one place (the lazily invoked init function), and document our overrides in doc/configuration.md.

To launch Shiny applications in the system browser you need the following configuration:

options(
  browser = I(Sys.getenv("R_BROWSER")),
  shiny.launch.browser = TRUE
)

An alternative to this approach is to recommend using the new hook that @jennybc is implementing in #1088. The approach implemented in this PR has the advantage that the user configuration also works in the R cli without any duplication.

@lionel- lionel- requested review from jennybc and juliasilge March 21, 2026 10:35
Copy link
Copy Markdown
Contributor

@juliasilge juliasilge left a comment

Choose a reason for hiding this comment

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

Super nice to have the options more consolidated here! 🙌

I just tried out some of the ways we see folks trying to use launch.browser as outlined in posit-dev/positron#8450, like runApp(app, launch.browser = TRUE) or shinyApp(ui, server, options = list("launch.browser" = TRUE)), and it seems like those still are not working. Is it possible for us make that work for Shiny users?

I also notice that you cannot control this behavior just with the shiny.launch.browser option, which I think is going to continue to be surprising for folks and not really what they're expecting. Is it possible for us use that option to control what happens with browser?

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.

2 participants