ropensci-review-tools / pkgstats

Historical statistics of every R package ever
https://docs.ropensci.org/pkgstats/
17 stars 1 forks source link

"Error in file(filename, "r") : cannot open the connection" when running pkgcheck #14

Closed helske closed 3 years ago

helske commented 3 years ago

I'm trying to test my package with pkgcheck, but I get an error related to the file paths on Windows:

options(repos = c(
  ropenscireviewtools = "https://ropensci-review-tools.r-universe.dev",
  CRAN = "https://cloud.r-project.org"))

install.packages("pkgcheck")
library(pkgcheck)
mydir <- file.path(tempdir(), "test")
gert::git_clone("https://github.com/helske/bssm", path = mydir)
x <- pkgcheck(mydir)

results in Error in file(filename, "r") : cannot open the connection. With traceback() I see

10: file(filename, "r")
9: parse(file = f_full, keep.source = TRUE)
8: utils::getParseData(parse(file = f_full, keep.source = TRUE))
7: fn_var_call_graph_r(fns_r, fn_vars_r, path)
6: tags_data(path, has_tabs)
5: pkgstats::pkgstats(path)
4: withCallingHandlers(expr, warning = function(w) if (inherits(w, 
       classes)) tryInvokeRestart("muffleWarning"))
3: suppressWarnings(pkgstats::pkgstats(path))
2: pkgstats_checks(path)
1: pkgcheck(mydir)

And debugging fn_var_call_graph_r shows that the path argument is "C:\\Users\\jovetale\\AppData\\Local\\Temp\\RtmpAnZYNz/test" which is appended to for example with "C:/Users/jovetale/AppData/Local/Temp/RtmpAnZYNz/kLLHePAK/R/zzz.R" when building f_full, leading to a nonexistent path such as "C:\\Users\\jovetale\\AppData\\Local\\Temp\\RtmpAnZYNz\\test\\C:\\Users\\jovetale\\AppData\\Local\\Temp\\RtmpAnZYNz\\kLLHePAK\\R\\zzz.R" which cannot be parsed.

mpadge commented 3 years ago

Sorry for delayed response while I was on vacation. I can't reproduce that on a Linux environment, but will try a windows environment this coming week, and report back then.

mpadge commented 3 years ago

@helske Thanks for reporting this. It arose because pkgstats uses separate tagging libraries, one of which (ctags) constructs file paths with "winslash" separation ("\\"), and not with .Platform$file.sep ("/"). The above commits should fix for any version >= 0.0.0.297

mpadge commented 3 years ago

Re-opening because there seem to be a few additional issues. @helske Note that I'm also going to transfer the issue over to the pkgstats repo where the problem arises.

mpadge commented 3 years ago

All fixed now, via commits here and here.