wch / webshot

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

Help with "Error in rethrow_call" #97

Open rempsyc opened 4 years ago

rempsyc commented 4 years ago

After installing and loading:

install.packages("webshot")
webshot::install_phantomjs()
library(webshot)

I run:

example(webshot)

Or the examples in the readme.md:

webshot("https://www.r-project.org/", "r.png")

And I consistently get:

Error in rethrow_call(c_processx_exec, command, c(command, args), stdin,  : 
  Command 'C:/Users/username/Documents/R/win-library/3.6/processx/bin/x64/supervisor.exe' not found @win/processx.c:983 (processx_exec)
Type .Last.error.trace to see where the error occured

Any idea why?

wch commented 4 years ago

It sounds like your installation of processx has a problem. Try reinstalling it (in a new R session).

rempsyc commented 4 years ago

I reinstalled processx in a new R session, but same error. So I manually uninstalled from RStudio and reinstalled again, but same thing.

I wonder whether it could be due to my username having spaces and accents (though I cannot change it). I know it has given me some trouble with other packages in the past. Also, my last error trace:

> .Last.error.trace

 Stack trace:

 1. webshot:::webshot("https://www.r-project.org/", "r.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. processx:::supervisor_watch_pid(self$get_pid())
 7. processx:::supervisor_ensure_running()
 8. processx:::supervisor_start()
 9. process$new(supervisor_path(), args = c("-p", Sys.getpid(), "-i",  ...
 10. .subset2(public_bind_env, "initialize")(...)
 11. processx:::process_initialize(self, private, command, args, stdin,  ...
 12. rethrow_call(c_processx_exec, command, c(command, args), stdin,  ...

 x Command 'C:/Users/username/Documents/R/win-library/3.6/processx/bin/x64/supervisor.exe' not found @win/processx.c:994 (processx_exec)
wch commented 4 years ago

If this causes the same error, then the problem is definitely with processx:

processx::process$new("echo", "hello", supervise = TRUE)

Weird characters could definitely be a problem in launching the processx supervisor. I suggest filing an issue at https://github.com/r-lib/processx/issues, and report which weird characters you have in the path.

rempsyc commented 4 years ago

Correct! The command does output the same error. I'll reach out to processx. Thanks.

Note: actually it isn't the same command that isn't found but pretty close so definitely something with processx.

> process$new("echo", "hello", supervise = TRUE)

Error in rethrow_call(c_processx_exec, command, c(command, args), stdin,  : 
  Command 'echo' not found @win/processx.c:994 (processx_exec)
Type .Last.error.trace to see where the error occured
wch commented 4 years ago

Oh, I forgot that windows might not have echo. Try dir instead of echo and see what message that gives.

rempsyc commented 4 years ago

Same (Windows 10 here).

> process$new("dir", "hello", supervise = TRUE)

Error in rethrow_call(c_processx_exec, command, c(command, args), stdin,  : 
  Command 'dir' not found @win/processx.c:994 (processx_exec)
Type .Last.error.trace to see where the error occured

> .Last.error.trace

 Stack trace:

 1. process$new("dir", "hello", supervise = TRUE)
 2. .subset2(public_bind_env, "initialize")(...)
 3. processx:::process_initialize(self, private, command, args, stdin,  ...
 4. rethrow_call(c_processx_exec, command, c(command, args), stdin,  ...

 x Command 'dir' not found @win/processx.c:994 (processx_exec) 
gaborcsardi commented 4 years ago

Oh, I forgot that windows might not have echo. Try dir instead of echo and see what message that gives.

FWIW dir is also not a Windows executable:

> Sys.which("dir")
dir
 ""
> Sys.which("echo")
echo
  ""
> Sys.which("cmd")
                             cmd
"C:\\Windows\\SYSTEM32\\cmd.exe"
rempsyc commented 4 years ago

@wch Update: problem seems fixed(!) after updating to R version 4.0.2 for:

library(webshot)
webshot("https://www.r-project.org/", "r.png")

@gaborcsardi is correct I believe as process$new("dir", "hello", supervise = TRUE) still doesn't work though.

Thanks to you all!