Loading when the package name is invalid
malcolmbarrett opened this issue · 3 comments
I'm very interested in using DESCRIPTION
files for non-package projects. One of my favorite benefits is being able to load_all()
. Unfortunately, if the name of the project is not a valid R package name, load_all()
errors. IMO, it shouldn't be load_all()
's job to check the name, but having read the source code, I see it's a bit more complicated than that:
Lines 123 to 131 in 21675ec
As it's actually tools running a more complete check on the DESCRIPTION
file.
Ignoring the fact that I could get around this by sanitizing the name in the DESCRIPTION
file, is there another approach that could be used here to facilitate better use of loading in non-package projects? E.g. run a more custom check on the DESCRIPTION
file with desc or capture and ignore (or just warn) when the problem is not a big deal (like the name)?
Edit: Actually, now that I'm looking at tools:::.check_package_description()
, this seems like stuff that would all be caught in R CMD check anyway. Does something this complete need to be run at the loading stage?
I think we can remove it. While it may catch some uses for load_all() in the wrong directory the tools code doesn't actually throw an error in many cases.
Possibly we could just call rprojroot::find_package_root_file()
to find the package root, erroring otherwise.
All it does is check there is a description starting with ^Package:
That sounds perfect to me. That is the same way that usethis:::is_package()
defines a package, so IMO rprojroot::find_package_root_file()
is ideal for consistency
Happy to PR if you want
Sure a PR would be great