Skip to content

Commit

Permalink
Added guidance on dealing with chromote headless mode (#137)
Browse files Browse the repository at this point in the history
* Added guidance on dealing with chromote headless mode

* Fixing some typos in shinytest2 guidance
  • Loading branch information
rmbielby authored Jan 21, 2025
1 parent be6fde0 commit 49cf928
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
/.quarto/
*_cache/
_site/
site_libs/

.DS_Store
30 changes: 30 additions & 0 deletions learning-development/r.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,36 @@ That command should return the path that you entered for Chrome.

---

### shinytest2 - Old headless mode error message

---

When shinytest2 runs a Chrome or Edge browser window, it runs it in something called "headless mode", which effectively means it's running the browser in the background without you seeing the window on your desktop. The way headless mode works in Chrome and Edge recently changed, which triggers an error in shinytest2 if you haven't updated your R settings to allow for this.

The resulting error should look something like the following.

```
Error in with_random_port(launch_chrome_impl, path = path, args = args) :
Cannot find an available port. Please try again.
Caused by error in startup():
! Failed to start chrome. Error:
Old Headless mode has been removed from the Chrome binary. Please use the new
Headless mode (https://permanently-removed.invalid/docs/chromium/new-headless)
or the chrome-headless-shell which is a standalone implementation of the old
Headless mode (https://permanently-removed.invalid/blog/chrome-headless-shell).
```

To fix this issue, you just need to let R know that you want chromote sessions to run with the "new" headless mode. This can be done by setting a system variable in your .Renviron file as follows:

- open your .Renviron file for editing (for example, in the R console run `usethis::edit_r_environ()`)
- add the line `CHROMOTE_headless="new"` to the .Renviron file (and make sure the file ends in an empty line)
- Save the .Renviron file
- Restart your R session

Now you should be able to run `shinytest2::test_app()` as normal.

---

## Using R with ADA / Databricks

See our [guidance on how to connect to Databricks SQL Warehouse from R Studio](../ADA/databricks_rstudio_sql_warehouse.html), and [how to connect to Databricks personal cluster from R studio](../ADA/databricks_rstudio_personal_cluster.html)
Expand Down
5 changes: 4 additions & 1 deletion writing-visualising/dashboards_rshiny.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,10 @@ There are a couple of potential issues that you may run into when completing mig

---

Shinytest2 makes use of the Chromote package, which needs to connect to your local instance of Google Chrome. Please make sure you have Google Chrome installed before you attempt to use shinytest2, otherwise it will not work. Sometimes your copy of Chrome might be installed in a different place to where Chromote expects to find it, which means that your tests will not be able to run. There is information on how to resolve this issue [in the Tips for Using R section](../learning-development/r.html#shinytest2---invalid-path-to-chrome-error-message)
Shinytest2 needs to connect to your local copy of either MS Edge or Google Chrome by running a chromote session. The following issues can occur when shinytest2 tries to connect to run a Chromote session:

- [R can't find Edge or Chrome / invalid path to chromote](../learning-development/r.html#shinytest2---invalid-path-to-chrome-chromote-error-message)
- [Failed to launch Chrome / Edge due to trying to run in **old headless mode**](../learning-development/r.html#shinytest2---old-headless-mode-error-message)

---

Expand Down

0 comments on commit 49cf928

Please sign in to comment.