Open fh-mthomson opened 2 months ago
Thank you @fh-mthomson for the suggestion! This is on our radar and we'll be looking into improving the documentation for Workbench users, ideally in the Workbench Admin guide as suggested.
In the mean time, we welcome any tips, tricks, or gotchas in this thread for anyone who has successfully used Chrome and chromote in Workbench.
Like reported in https://github.com/rstudio/rstudio/issues/12960#issuecomment-2204757227 we also experience the following issue when using chromote
directly or indirectly through other packages, like gt
, webshot
etc:
Error in `with_random_port()`:
! Cannot find an available port. Please try again.
Caused by error:
! Native call to `processx_exec` failed
Caused by error:
! cannot start processx process '/opt/R/4.4.1/lib/R/site-library/processx/bin/supervisor' (system error 13, Permission denied) @unix/processx.c:613 (processx_exec)
---
Backtrace:
▆
1. └─chromote::ChromoteSession$new()
2. └─chromote (local) initialize(...)
3. └─chromote::default_chromote_object()
4. ├─chromote::set_default_chromote_object(Chromote$new())
5. └─Chromote$new()
6. └─chromote (local) initialize(...)
7. └─Chrome$new()
8. └─chromote (local) initialize(...)
9. └─chromote:::launch_chrome(path, args)
10. └─chromote:::with_random_port(launch_chrome_impl, path = path, args = args)
11. └─rlang::abort(...)
However, I've found that if I initialise a new project and initialise renv
:
new_proj <- "~/chromote_test"
create.dir(new_proj)
renv::init(project = new_proj)
and within the project create the chromote_test.R
script containing:
library(chromote)
b <- chromote::ChromoteSession$new()
b$Page$navigate("https://www.google.com")
b$screenshot()
b$close()
Snapshot the dependency:
> renv::snapshot()
The following package(s) will be updated in the lockfile:
# CRAN -----------------------------------------------------------------------
- AsioHeaders [* -> 1.22.1-2]
- chromote [* -> 0.2.0]
- cpp11 [* -> 0.4.7]
- curl [* -> 5.2.1]
- fastmap [* -> 1.2.0]
- jsonlite [* -> 1.8.8]
- later [* -> 1.3.2]
- magrittr [* -> 2.0.3]
- processx [* -> 3.8.4]
- promises [* -> 1.3.0]
- ps [* -> 1.7.7]
- R6 [* -> 2.5.1]
- Rcpp [* -> 1.0.13]
- rlang [* -> 1.1.4]
- websocket [* -> 1.4.2]
and THEN open up my chromote_test.R
script and execute it runs without failing:
> library(chromote)
> b <- chromote::ChromoteSession$new()
> b$Page$navigate("https://www.google.com")
$frameId
[1] "5DDD205F5A7F197F5D7A527EAC5F8767"
$loaderId
[1] "CD7996E97F2E635F4B9D0B371F61977D"
> b$screenshot()
[1] "screenshot.png"
> b$close()
[1] TRUE
and a nice screenshot appears:
> list.files()
[1] "chromote_test.R" "chromote_test.Rproj" "renv" "renv.lock" "screenshot.png"
This means I can circumvent the error by doing some (not particular nice) handling by sending the session start to a new project with renv
initialised. But I cannot, for the love of god, figure what it is renv
is changing in the environment in order for this to work. It must be masking either functions or paths, but I cannot see neither in renv
or chromote
what should be causing this "nice" side-effect.
Any input to where I should search would be appreciated 🙏
Bolster docs to summarize recommended set of dependencies needed to be able to run
chromote
in Workbench (leveraging findings in #150, #103) since these are standard dependencies forwebshot2
andshinytest2
.Alternatives: