question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Open in the browser when shiny.launch.browser is TRUE

See original GitHub issue

Is your feature request related to a problem? Please describe.

One current point of friction when using R with VSCode is that the options(shiny.launch.browser = TRUE) doesn’t open the shiny app in the default web browser — the default behavior in the RStudio IDE. https://shiny.rstudio.com/reference/shiny/0.14/shiny-options.html

Right now it opens in a VSCode tab, and you have to pop it out to get in the browser. That’s kind of not complex per se, but you end up doing that a lot and with a lot of useless tabs in VSCode you have to manually close.

Describe the solution you’d like

I’d love the shiny app to be opened in the web browser whenever shiny.launch.browser is TRUE.

Describe alternatives you’ve considered

I don’t think there are any alternatives so far.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ColinFaycommented, Dec 8, 2021

From the documentation at shiny.rstudio.com/reference/shiny/0.14/runApp.html, the definition of shiny.launch.browser seems to be open browser in general rather than toggling open in external browser or open in RStudio, i.e. if it is FALSE then it will not try to open any window to show the shiny app.

Yes, shiny.launch.browser = TRUE opens the default web browser, shiny.launch.browser = FALSE will not open anything (it currently works as expected), and you can also do options(shiny.launch.browser = rstudioapi::viewer) to force the view in the RStudio viewer. Not sure if this last should be supported or not, and how?

In you case, you might want to put the following in your VS Code settings:

Awesome, thanks a lot !!

Looks like inside the browser call, we could check if environmentName(parent.env(parent.frame(2))) == “shiny”) to identify a shiny app calling browser.

In case it can help, what shiny does for displaying the app is :

> utils::browseURL("https://google.com")
VSCode WebView only supports showing local http content.
Opening in external browser...
Browsing https://google.com

Whereas opening a local html will render inside VSCode (hence the opening of the local shiny app inside VSCode).

0reactions
renkun-kencommented, Dec 10, 2021

Also, you could use

options(shiny.launch.browser = function(...) .vsc.browser(..., viewer = FALSE))

to force opening shiny apps in external web browser.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Opening Shiny App directly in the default browser
4 Answers 4 · Step 1: Locate where your .exe files are installed for all you browsers, then add the following: · Step...
Read more >
runApp - Shiny
If true, the system's default web browser will be launched automatically after the app is started. Defaults to true in interactive sessions only....
Read more >
Shiny Tip: Choose Where to Run App with an Option
R in RStudio, you can choose to run the app in the Viewer Pane, a new Window, or in an External browser window....
Read more >
Potential bug in runApp(launch.browser = FALSE) · Issue #1101
Suppose I'm in RStudio and the default app launcher is set to the Viewer Pane. If I use runApp(app) then the app runs...
Read more >
gridsampler function - RDocumentation
This function starts the gridsampler shiny app. ... gridsampler: Run gridsampler app. Description ... Boolean, set TRUE to open the app in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found