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

parse_packages() behaviour with empty file. #107

Closed
jameslairdsmith opened this issue Mar 8, 2024 · 4 comments
Closed

parse_packages() behaviour with empty file. #107

jameslairdsmith opened this issue Mar 8, 2024 · 4 comments

Comments

@jameslairdsmith
Copy link
Contributor

Working with JFROG Artifactory, one can occasionally encounter an empty PACKAGES file. I think it's nice to warn when this happens (which is the current behaviour, see below), although an argument can be made for throwing an error. If it remains a warning, it would be nice to make it more specific.

library(pkgcache)
tmp <- tempfile("PACKAGES")
writeLines("", tmp)
parse_packages(tmp)
#> Warning in structure(.x, class = c(.class, "data.frame"), row.names = .set_row_names(.size), : Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
#>   Consider 'structure(list(), *)' instead.
#> # A data frame: 0 × 0

Created on 2024-03-08 by the reprex package (v2.0.1)

@jameslairdsmith
Copy link
Contributor Author

It could also be zero lines.

@gaborcsardi
Copy link
Member

The warning is not intentional, TBH I am not sure if an edge case should throw a warning.

Why is a warning useful for you?

@jameslairdsmith
Copy link
Contributor Author

In my case I was scanning through all the PACKAGES files in a CRAN-like repository, using parse_packages() to parse them and combining them into a single data frame (with an annotation column saying which PACKAGES file they came from). The warning alerted me that one of the files was empty (because it was a directory that had been created by accident), although I didn't know what was wrong until I dug into it.

But seeing as this is a very uncommon use case, it's perhaps not worth the warning.

@gaborcsardi
Copy link
Member

gaborcsardi commented Mar 8, 2024

OK, let me think about this at the next pkgcache release.

I am a bit reluctant to add a warning, because I can imagine that some PACKAGES files are empty, e.g. if you are not serving macOS or Windows binaries from the repo. Although in practice currently the PACKAGES file is completely missing in this case.

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