Search code examples
rgithubcran

Make CRAN R package suggest GitHub R package


I want to use the R package BOLTSSIRR available on GitHub in my R package, which I want to upload to CRAN.

I listed BOLTSSIRR under Suggests: in the DESCRIPTION file and made the link to GitHub available using Additional_repositories: https://github.com/daviddaigithub/BOLTSSIRR.

However, running R CMD check --as-cran I get:

Suggests or Enhances not in mainstream repositories:
  BOLTSSIRR
Availability using Additional_repositories specification:
  BOLTSSIRR   no   ?                                          
  ?            ?   https://github.com/daviddaigithub/BOLTSSIRR
Additional repositories with no packages:
  https://github.com/daviddaigithub/BOLTSSIRR

So the GitHub link does not seem to get recognized in the check. Might I have to change something here?


Solution

  • As you found, you can't use Remotes in a CRAN package. What you need to do is to make sure the .tar.gz file for the package you are depending on is available somewhere. Github doesn't do that automatically, because https://github.com/daviddaigithub/BOLTSSIRR isn't set up as a package repository.

    The solution is to create your own small repository, and keep copies of non-CRAN packages there. The drat package (available here: https://github.com/eddelbuettel/drat) makes this easy as long as you have a Github account: follow the instructions here: https://github.com/drat-base/drat. In summary:

    1. Fork https://github.com/drat-base/drat into your account, and clone it to your own computer.
    2. Enable Github Pages with the docs/ folder in the main branch.
    3. Install the drat package into R using remotes::install_github("eddelbuettel/drat"). (I assume this version will make it to CRAN eventually; if you use the current CRAN version instructions are slightly more complicated.)
    4. Build the package you want to insert. You need the source version; you might want binaries too, if those are hard for your users to build.
    5. Run options(dratBranch="docs"); drat::insertPackage(...) to insert those files into your repository.
    6. Commit the changes, and push them to Github.
    7. In the package that needs to use this non-CRAN package, add
      Additional_repositories: https://yourname.github.io/drat
      to the DESCRIPTION.

    You will be responsible for updating your repository if BOLTSSIRR is updated. This is good because the updates might break yours: after all, it's still in development mode. It's also bad because your users won't automatically get bug fixes.

    That's it, if I haven't missed anything!