How could I release an R package on github using github submodules?
Asked Answered
E

0

9

I have an R package on github. This R package has C++ dependencies which I include in /src.

The correct way I would normally do this (outside of R) is create submodules within the github repo, which could link to the correct commits as dependencies.

The problem with doing this in R is that these subdirectories will be interpreted as "empty" and the installation won't work, e.g.

> devtools::install_github("reponame/packagename")
* checking for file 'bambi/DESCRIPTION' ... OK
* preparing 'packagename':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
...

So, the checking for empty or unneeded directories causes the errors, because the submodules are interpreted as empty subdirectories. Therefore, it cannot find the necessary dependencies, and I'll run into a fatal error upon build

(1) Yes, one way to solve this is to physically put the dependencies within the R package. That does defeat the purpose of submodules though, which are very useful.

(2) It appears using the following argument works:

devtools::install_git("reponame/packagename", args="--recursive")

The problem with this is, this isn't default behavior. I'm nervous about getting dozens of github issues from users who ran devtools::install_git("reponame/packagename") and didn't read the fine print in the README

(3) Is there a better way? What is the standard method of releasing R packages as a github repo using submodules?

Erratum answered 22/5, 2018 at 18:40 Comment(8)
Probably a better question for the devtools developers.Differentia
Use a drat repository. Trivial to setup on GH. Allows for normal package updates. You have control which versions go into there.Valuation
@RalfStubner This github.com/eddelbuettel/drat?Erratum
@Erratum Yes. You can clone that repository as starting point. Users can install the drat package from CRAN.Valuation
Please create only one issue. Other people interested in that feature can indicate it there. BTW, remotes might be the better place to add the feature request.Valuation
@RalfStubner I don't follow---why remotes instead of devtools?Erratum
IIRC the install_* functions are meant to be migrated to remotes.Valuation
I don't get it. If you are using submodules, those will not be empty directories unless the repositories are themselves empty. If you want to ignore those folders when you build your package, you can do so through an .Rbuildignore file, adding a line like this: ^src/your_submodule/*.Pt

© 2022 - 2024 — McMap. All rights reserved.