Reputation: 1409
Running the below code will sometimes fail and return the attached error message.
webshot2::webshot(url = "~/a_web_page.html", file = "~/an_image.png")
Error in launch_chrome(path, args) :
Failed to start chrome. Error: [1208/102720.412050:ERROR:filesystem_posix.cc(63)] mkdir /tmp/Crashpad/new: Permission denied (13)
[1208/102720.412409:ERROR:socket.cc(120)] recvmsg: Connection reset by peer (104)
Update:
This error can also pop up when rendering an rmarkdown file which includes HTML widgets (e.g. plotly plots) to word output.
Upvotes: 4
Views: 1470
Reputation: 1409
The reason is that the underlying chromote
R package tries to launch chrome via launch_chrome()
, which then again attempts to write into the file system at /tmp/Crashpad/new
.
If you navigate to the /tmp/Crashpad/new
directory you will likely see that another user owns this directory. This also means that this problem is probably specific to RStudio Server environments synchonously used by several users. It also explains why the problem does not occur right away. The first person running the code should not run into this Issue. However, everyone thereafter will.
One solution for the Problem is to deactivate the crash reporter before you take the screenshot. Of course this means no crash reports.
chromote::set_chrome_args("--disable-crash-reporter")
webshot2::webshot(url = "~/a_web_page.html", file = "~/an_image.png")
If you need the crash reports for some reason you can also ask the server admin to appropriately adjust the file system permissions.
Update:
There are scenarios where using chromote::set_chrome_args("--disable-crash-reporter")
can trigger a subsequent Error: Running as root without --no-sandbox is not supported.
when running code as root (e.g. can be the case in a CI/CD pipeline). For such cases it is likely best to configure /tmp/Crashpad/
permissions instead of disabling the chrome crash reporter.
Upvotes: 6