wch / webshot

Take screenshots of web pages from R
http://wch.github.io/webshot/
227 stars 40 forks source link

"system error 5, Access is denied" : On Windows 10, cannot take screenshot #98

Open engti opened 4 years ago

engti commented 4 years ago

On a windows 10 laptop, I am unable to take screenshots. When I issue the command, I get an error.

> webshot("http://rstudio.github.io/leaflet/", "screenshot.png")
Error in rethrow_call(c_processx_exec, command, c(command, args), stdin,  : 
  create process 'C:\Users\username\AppData\Roaming/PhantomJS/phantomjs.exe' (system error 5, Access is denied.
) @win/processx.c:1042 (processx_exec)

And then I used last.error.trace to get

Stack trace:

 1. webshot:::webshot("http://rstudio.github.io/leaflet/", "screenshot.png")
 2. webshot:::phantom_run(args)
 3. callr::process$new(phantom_bin, args = args, stdout = "|", stderr = "|",  ...
 4. .subset2(public_bind_env, "initialize")(...)
 5. processx:::process_initialize(self, private, command, args, stdin,  ...
 6. rethrow_call(c_processx_exec, command, c(command, args), stdin,  ...

 x create process 'C:\Users\username\AppData\Roaming/PhantomJS/phantomjs.exe' (system error 5, Access is denied.
) @win/processx.c:1042 (processx_exec)

Additional Info

Installed the webshot package by: remotes::install_github("wch/webshot")

Installed the Phantom JS dependency:

install_phantomjs(version = "2.1.1",
                  baseURL = "https://github.com/wch/webshot/releases/download/v0.3.1/",
                  force = FALSE)

Permissions

Then I took a look at the permissions of the folder where Phantom JS is installed. And found it to be "Read Only". Screenshot below. Folder Location: C:\Users\username\AppData\Roaming

Resetting permission did not help. Opening the permissions tab again, showed that it was back to its "Read Only" status.

image

Thoughts

Perhaps if we install the Phantom JS dependency on another folder, it might help? Is there a way for me to set the install directory path for Phantom JS to another place on my device?

Looking at the _installphantomjs function, there is the following block:

    if (is_windows()) {
        zipfile <- sprintf("phantomjs-%s-windows.zip", 
            version)
        download(paste0(baseURL, zipfile), zipfile, mode = "wb")
        utils::unzip(zipfile)
        zipdir <- sub(".zip$", "", zipfile)
        exec <- file.path(zipdir, "bin", "phantomjs.exe")
    }

Is there a temporary fix I can use?

Thanks for reading.