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?

ShanZhengYang
  • 16,511
  • 49
  • 132
  • 234
  • 3
    Probably a better question for the [devtools developers](https://github.com/r-lib/devtools/issues). – MrFlick May 22 '18 at 19:14
  • 1
    Use a drat repository. Trivial to setup on GH. Allows for normal package updates. You have control which versions go into there. – Ralf Stubner May 22 '18 at 19:48
  • @RalfStubner This https://github.com/eddelbuettel/drat? – ShanZhengYang May 22 '18 at 19:55
  • @ShanZhengYang Yes. You can clone that repository as starting point. Users can install the drat package from CRAN. – Ralf Stubner May 22 '18 at 19:58
  • 1
    Please create only one issue. Other people interested in that feature can indicate it there. BTW, [remotes](https://github.com/r-lib/remotes/issues) might be the better place to add the feature request. – Ralf Stubner May 23 '18 at 04:41
  • @RalfStubner I don't follow---why remotes instead of devtools? – ShanZhengYang May 23 '18 at 16:48
  • IIRC the `install_*` functions are meant to be migrated to `remotes`. – Ralf Stubner May 23 '18 at 18:23
  • 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/*`. – anymous.asker Sep 01 '21 at 00:15

0 Answers0