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

Check imports when generating the NAMESPACE file #1409

Closed
gaborcsardi opened this issue Jul 26, 2022 · 1 comment · Fixed by #1458
Closed

Check imports when generating the NAMESPACE file #1409

gaborcsardi opened this issue Jul 26, 2022 · 1 comment · Fixed by #1458
Labels
feature a feature request or enhancement
Milestone

Comments

@gaborcsardi
Copy link
Member

Ie. for an @importFrom pkg fun we could check if fun is an exported function of pkg.

Otherwise R will throw a warning when the package is loaded, and it is sometimes hard to deduct where the warning is coming from.

@gaborcsardi gaborcsardi added the feature a feature request or enhancement label Jul 26, 2022
@MichaelChirico
Copy link
Contributor

MichaelChirico commented Jan 16, 2023

Not just a warning*, this prevents compilation (at least on R 4.1.3).

This happens too often in cases where I'm dumping all the imports into the top of a file (a la #include statements) and neglect to terminate the block with a NULL, e.g.

# in R/foo.R

#' @importFrom dplyr group_by
# <- should be a NULL here to terminate the block, but forgot it

#' Here is a function
#' @export
foo <- identity

roxygenize() makes this NAMESPACE:

# Generated by roxygen2: do not edit by hand

export(foo)
importFrom(dplyr,"function")
importFrom(dplyr,Here)
importFrom(dplyr,a)
importFrom(dplyr,group_by)
importFrom(dplyr,is)

And compilation fails:

R CMD INSTALL .

* installing to library ‘...’
* installing *source* package ‘tmpPkg’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
Error: object ‘function’ is not exported by 'namespace:dplyr'
Execution halted
ERROR: lazy loading failed for package ‘tmpPkg’

+💯 to difficulty dealing with this error without a trained eye.

* Oh, I see, roxygenize() throws a warning. But we don't always see the warning if other processes are calling roxygenize() or it gets buried.

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

Successfully merging a pull request may close this issue.

3 participants