Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

renv chokes scanning dependencies erroring ungracefully #772

Closed
MilesMcBain opened this issue Jun 9, 2021 · 1 comment
Closed

renv chokes scanning dependencies erroring ungracefully #772

MilesMcBain opened this issue Jun 9, 2021 · 1 comment

Comments

@MilesMcBain
Copy link

MilesMcBain commented Jun 9, 2021

Error was initially reported to me in MilesMcBain/capsule#9

Running renv::init(bare = TRUE) in this project (https://github.com/njtierney/njtcv/tree/b002f11b78aac3f9c239dfba6d71895c06ca0408) gives:

[nav] r$> renv::init(bare = TRUE)
WARNING: One or more problems were discovered while enumerating dependencies.

Error in split.default(x = seq_len(nrow(x)), f = f, drop = drop, ...) :
  group length is 0 but data length > 0
Traceback (most recent calls last):
11: renv::init(bare = TRUE)
10: renv_dependencies_scope(project, action = "init")
 9: withCallingHandlers(dependencies(path, progress = FALSE, errors = errors,
        dev = TRUE), renv.dependencies.error = renv_dependencies_error_handler(message,
        errors))
 8: dependencies(path, progress = FALSE, errors = errors, dev = TRUE)
 7: renv_dependencies_impl(path = path, root = root, progress = progress,
        errors = errors, dev = dev, ...)
 6: renv_dependencies_report(errors)
 5: split(bound, bound$file)
 4: split.data.frame(bound, bound$file)
 3: lapply(split(x = seq_len(nrow(x)), f = f, drop = drop, ...),
        function(ind) x[ind, , drop = FALSE])
 2: split(x = seq_len(nrow(x)), f = f, drop = drop, ...)
 1: split.default(x = seq_len(nrow(x)), f = f, drop = drop, ...)

I spelunked into the innards of init and found the problems object you pull out of global state in renv_dependencies_report appears to have an unexpected shape:

[ins] Browse[8]> problems
[[1]]
[[1]]$file
NULL

[[1]]$error
<simpleError in parse(text = text, ...): <text>:1:1: unexpected '<'
1: <
    ^>

Although the file was NULL I grepped for < and found some potentially edge-case-smelling usage in a file containing this code:

embolden_name <- function(string,
                          name = "Nicholas J. Tierney"){
  str_replace_all(string = string,
                  pattern = name,
                  replacement = glue::glue("\\\\textbf{<name>}",
                                           .open = "<",
                                           .close = ">"))
}

Renaming the file (embolden_name.R) to have a .txt extension and rerunning init(bare = TRUE) worked.

So I think it's a parsing edge case, but I don't think renv should be performing parsing anyway due to bare = TRUE (see: #771)

Unfortunately, I have to tap out debugging there because the data is being maintained in global state via side effects in ways that I can't come to grips with quickly.

- Session info ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------   
 setting  value
 version  R version 4.0.5 (2021-03-31)
 os       Windows 10 x64
 system   x86_64, mingw32
 ui       RTerm
 language (EN)
 collate  English_Australia.1252
 ctype    English_Australia.1252
 tz       Australia/Brisbane
 date     2021-06-09

- Packages ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------   
 ! package     * version     date       lib source
 P cli           2.5.0.9000  2021-05-23 [?] local
 R digest        0.6.27      <NA>       [?] <NA>
 R evaluate      0.14        <NA>       [?] <NA>
 R fastmap       1.1.0.9000  <NA>       [?] <NA>
 R htmltools     0.5.1.9005  <NA>       [?] <NA>
 R jsonlite      1.7.2       <NA>       [?] <NA>
 R knitr         1.33        <NA>       [?] <NA>
 R renv          0.13.2-29   <NA>       [?] <NA>
 R rlang         0.4.11.9000 <NA>       [?] <NA>
 R rmarkdown     2.8         <NA>       [?] <NA>
   sessioninfo   1.1.1.9000  2021-06-03 [2] local
   withr         2.4.2.9000  2021-05-28 [2] local
 R xfun          0.22        <NA>       [?] <NA>
 R yaml          2.2.1       <NA>       [?] <NA>
@kevinushey
Copy link
Collaborator

Thanks! Should be fixed up now.

(the issue was indeed that calls to glue::glue() with non-default open and close delimiters was tripping up renv)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants