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

Bug: Suggested packages should be used conditionally #101

Closed
munterfi opened this issue Dec 23, 2020 · 1 comment · Fixed by #105 or #107
Closed

Bug: Suggested packages should be used conditionally #101

munterfi opened this issue Dec 23, 2020 · 1 comment · Fixed by #105 or #107
Assignees
Labels
bug Something isn't working

Comments

@munterfi
Copy link
Owner

munterfi commented Dec 23, 2020

CRAN complains about missing if(requireNamespace("pkgname")) statements in the package vignettes:

This concerns packages

[... hereR ...]

Suggested packages should be used conditionally: see §1.1.3.1 of 'Writing R Extensions'. Some of these are hard to install on a platform without X11 such as M1 Macs: see the logs at https://www.stats.ox.ac.uk/pub/bdr/M1mac/.

You can check all of the suggested packages by setting environment variable R_CHECK_DEPENDS_ONLY=true -- see https://cran.r-project.org/doc/manuals/r-devel/R-ints.html#Tools .

Please correct ASAP and before 2021-01-12 to safely retain the package on CRAN.

According to 1.1.3.1 Suggested packages, the solution is:

However, using require for conditioning in package code is not good practice as it alters the search path for the rest of the session and relies on functions in that package not being masked by other require or library calls. It is better practice to use code like:

if (requireNamespace("rgl", quietly = TRUE)) {
  rgl::plot3d(...)
} else {
  ## do something else not involving rgl.
}

Note the use of rgl:: as that object would not necessarily be visible (and if it is, it need not be the one from that namespace: plot3d occurs in several other packages). If the intention is to give an error if the suggested package is not available, simply use e.g. rgl::plot3d.

In the vignettes of hereR this is pointing to the mapview, leafpop and ggplot2 packages, which are listed as suggested packages. There seem to be two solutions:

  1. Add the statement above to the vignettes and come up with a fallback solution if the packages are not present.
  2. Remove them from the vignettes and suggested packages in DESCRIPTION and use the fall back solution instead. This would also be preferable with regard to the size of the vignettes.
@munterfi munterfi added the bug Something isn't working label Dec 23, 2020
@munterfi munterfi self-assigned this Dec 23, 2020
@munterfi
Copy link
Owner Author

munterfi commented Jan 1, 2021

Added if(requireNamespace("pkgname")) statements for suggested packages in the vignettes.

Run export R_CHECK_DEPENDS_ONLY=true && R CMD check --as-cran hereR_0.5.2.9000.tar.gz to check only with packages in depends:

0 errors ✓ | 0 warnings ✓ | 0 notes ✓

R CMD check succeeded

Checks using the R-hub builder API (rhub::check_for_cran()) are also passing.

munterfi added a commit that referenced this issue Jan 1, 2021
Use suggested packages conditionally, closes #101.
@munterfi munterfi mentioned this issue Jan 1, 2021
@munterfi munterfi mentioned this issue Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant