dmurdoch / rgl

rgl is a 3D visualization system based on OpenGL. It provides a medium to high level interface for use in R, currently modelled on classic R graphics, with extensions to allow for interaction.
https://dmurdoch.github.io/rgl/
GNU General Public License v2.0
85 stars 20 forks source link

`requireWebshot2`: use `Sys.which` instead of `file.exists`? #376

Closed stla closed 1 year ago

stla commented 1 year ago

Hello,

The function requireWebshot2 is:

requireWebshot2 <- function() {
  suppressMessages(res <- requireNamespace("webshot2", quietly = TRUE))
  if (res) 
    res <- requireNamespace("chromote") &&
           !is.null(path <- chromote::find_chrome()) &&
           nchar(path) > 0 &&
           file.exists(path)
  res
}

However chromote::find_chrome() returns chrome for me, which is in the system path. Instead of file.exists(path), which returns FALSE for me, can't we use nchar(Sys.which(path)) > 0?

Now I confess I didn't seriously study this question.


dmurdoch commented 1 year ago

The chromote::find_chrome function is documented to return a path. Looking at the source, I see it starts with

if (Sys.getenv("CHROMOTE_CHROME") != "") {
    return(Sys.getenv("CHROMOTE_CHROME"))
}

so it's not checking if you have the location set to something else. So this is an error on your system, or in the chromote docs, but it seems worthwhile to work around it as you suggest.

stla commented 1 year ago

Ah yes sorry, actually that's me who defined Sys.setenv(CHROMOTE_CHROME = "chrome").

dmurdoch commented 1 year ago

I think this should be dealt with by chromote rather than rgl, so I'm closing this issue.