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

Document steps needed to use chromote in Posit Workbench #179

Open
fh-mthomson opened this issue Sep 19, 2024 · 2 comments
Open

Document steps needed to use chromote in Posit Workbench #179

fh-mthomson opened this issue Sep 19, 2024 · 2 comments

Comments

@fh-mthomson
Copy link

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 for webshot2 and shinytest2.

Alternatives:

@gadenbuie
Copy link
Member

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.

@NNaikp
Copy link

NNaikp commented Dec 2, 2024

System Details
RStudio 2024.04.2+764.pro1 "Chocolate Cosmos" Release (653611509504ac6640465e42d455d05dce98e1c4, 2024-06-05) for RHEL 8
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0, Quarto 1.5.57 (/opt/quarto/1.5.57/bin/quarto)

> R.version
               _                           
platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          4                           
minor          4.1                         
year           2024                        
month          06                          
day            14                          
svn rev        86737                       
language       R                           
version.string R version 4.4.1 (2024-06-14)
nickname       Race for Your Life   

With packages corresponding to:

options("repos" = c("CRAN" = "https://packagemanager.posit.co/cran/2024-08-06"))

Like reported in rstudio/rstudio#12960 (comment) 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 🙏

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

No branches or pull requests

3 participants