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

Unfriendly error for '@include zoo' instead of '@import zoo' #1497

Closed
MichaelChirico opened this issue Jul 4, 2023 · 3 comments · Fixed by #1544
Closed

Unfriendly error for '@include zoo' instead of '@import zoo' #1497

MichaelChirico opened this issue Jul 4, 2023 · 3 comments · Fixed by #1544
Labels
bug an unexpected problem or unintended behavior
Milestone

Comments

@MichaelChirico
Copy link
Contributor

The logic for processing @include could go for a sanity check. Using @include zoo by mistake gives some hard-to-trace error:

Warning in normalizePath(file.path(path, "R", collate)) :
  path[3]="...R/zoo": No such file or directory
Warning in file(con, "r") :
  cannot open file '...R/zoo': No such file or directory
Error in file(con, "r") : cannot open the connection
Calls: Main ... parse_package -> lapply -> FUN -> read_lines -> <Anonymous> -> file
In addition: Warning message:
'Collate' must contain a list of .R files

In retrospect this makes sense, but it took quite some time to debug. Is it valid to @include a non-R file? Couldn't we check file.exists() for @include directives to prevent this with a friendlier error?

@hadley hadley added the bug an unexpected problem or unintended behavior label Nov 1, 2023
@hadley
Copy link
Member

hadley commented Nov 1, 2023

Yup, could definitely do better here.

@hadley hadley added this to the v7.2.4 milestone Nov 2, 2023
@hadley
Copy link
Member

hadley commented Nov 15, 2023

This is a little trickier than I had thought because @include is handled specially (since it needs to be run before loading the package). Will need some custom code in generate_collate() to detect files that aren't found in R/, warn, and drop from the collate.

@hadley
Copy link
Member

hadley commented Nov 21, 2023

Whoops, accidentally committed part of an experiment in #1293

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants