RLesur/crrri

Problems on Mac: "Error: Cannot launch Chrome. Please add the path to your Chrome bin."

ulyngs opened this issue · 4 comments

I still can't get this up and running on Mac.

> library(crrri)
> chrome <- Chrome$new()
Running  --no-first-run --headless '--user-data-dir=/Users/ulyngs/Library/Application Support/r-crrri/chrome-data-dir-unsywfqr' \
  '--remote-debugging-port=9222'
Error: Cannot launch Chrome. Please add the path to your Chrome bin.

I tried to add the path to Google Chrome to the PATH variable in ~./bash_profile (as per these instructions, but I still get the same error.

I also tried to create a HEADLESS_CHROME variable in ~/.bash_profile but still get the same error.

Have anyone gotten this up and running successfully on a Mac? If so, I suggest we add instructions or pointers for how to do this to this part of the readme:

You only need a recent version of Chromium or Chrome. A standalone version works perfectly well on Windows. It is recommended to set the value of the HEADLESS_CHROME environment variable to the path of Chromium or Chrome (this is the same environment variable that is used in decapitated). Otherwise, you can use the bin argument of the Chrome class connect() method.

:)

cderv commented

Thank for the feedback. We don't have mac ourself so there may be some specificity

Is this working when you provide the binary path through the bin argument in chrome$new

chrome <- Chrome$new(bin = "<pathtochrome>")

also, can you also check Sys.getenv("HEADLESS_CHROME") in your Rsession before trying to launch chrome to see if R sees the variable correctly.

Thanks.

Hey,

I get it working that way:

library(crrri)
x <- Chrome$new("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome")
#> Running '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' \
#>   --no-first-run --headless \
#>   '--user-data-dir=/Users/colin/Library/Application Support/r-crrri/chrome-data-dir-yybuhaki' \
#>   '--remote-debugging-port=9222'
x
#> <HeadlessChrome/75.0.3770.100>
#>   url: http://localhost:9222/
#>   user-agent:
#>     "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/75.0.3770.100 Safari/537.36"
#>   Running: TRUE

Created on 2019-07-12 by the reprex package (v0.3.0)

Amazing, I got it working now!

What confused me was the wording "Otherwise, you can use the bin argument of the Chrome class connect() method" in README, from which I didn't understand that bin was an argument to Chrome$new(bin = )!

I have it working now by either

library(crrri)
chrome <- Chrome$new(bin = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome")
chrome$close()

or

library(crrri)
Sys.setenv(HEADLESS_CHROME = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome")
chrome <- Chrome$new()
chrome$close()

This works like pure magic!!!

cderv commented

What confused me was the wording "Otherwise, you can use the bin argument of the Chrome class connect() method" in README, from which I didn't understand that bin was an argument to Chrome$new(bin = )!

You're right this is confusing. I'll rewrite that ! Thanks !