Use GitHub Package R Actions - r

I was trying to use actions in a package I wrote. The issue is that the package actions uses remotes in its setup to install CRAN only packages.
Since the package I am working on depends on a non CRAN package that is present on GitHub, both coverage and R CMD checks fail. I tried to avoid this by naively downgrading to an earlier version of the package in depends but some functions are not exported. I am wondering if someone knows a workaround that might help(I cannot open an issue at actions since their support.md file discourages this).

If your package depends on a non-CRAN package, you must include under Remotes: rather than just Imports: in your DESCRIPTION file. Here you would have:
Imports:
actions
Remotes:
r-lib/actions
This will pass checks, but there is no work around for publishing to CRAN if any of your dependencies are not on CRAN, thus you'll get a warning if any packages are present in the Remotes field.
The alternative using Travis is adding r_github_packages: r-lib/actions to your .travis.yml.

After some time, I have found a workaround that for now is good enough if you want to test for the development version(like I wanted). You should include an install_github command in the check.yaml file. Here's an example:
- name: Install dependencies
run: |
install.packages(c("remotes","testthat"),dependencies=TRUE)
remotes::install_github("tidyverse/dplyr")
remotes::install_cran("covr")
shell: Rscript {0}
The above snippet fixed my issue because I wanted to depend on a future dplyr version. You can view the full yaml file here.

Related

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?
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:
Fork https://github.com/drat-base/drat into your account, and clone it to your own computer.
Enable Github Pages with the docs/ folder in the main branch.
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.)
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.
Run options(dratBranch="docs"); drat::insertPackage(...) to insert those files into your repository.
Commit the changes, and push them to Github.
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!

R Package Dependency in Github via Remotes not working

I'm developing an R package in Github (ConceptionTools) that depends on another R package (CreateFlowChart), also in Github. I have followed the instructions for defining remote dependencies. My DESCRIPTION file includes:
Imports: CreateFlowChart
Remotes: github::IMI-ConcePTION/CreateFlowChart
However, when I install my package, with the command:
devtools::install_github("IMI-ConcePTION/ConceptionTools")
This dependency is not installed. I simply get "skipping 1 packages not available: CreateFlowChart". It doesn't appear to be trying to use the Remote, since there is no error related to Github.
When I install the dependency directly, that works:
devtools::install_github("IMI-ConcePTION/CreateFlowChart")
Does anybody have any idea of what could be going on here? I'm racking my brain, as it seems to be a quite straightforward case of what the documentation shows. I'm using R 4.0.3 (on Windows 10) and devtools 2.3.2.
There was a typo in the name of the dependency package in its DESCRIPTION file.
This does not make the package fail when installing it directly, but it leads devtools not to find it as a dependency.

R package dependency error on travis-ci but not local machine

I am trying to build my first R package (GitHub link). It is currently passing all local checks with devtools::check(), but failing on Travis:
ERROR: dependency ‘Rmpfr’ is not available for package ‘streamDepletr’
Looking at the Installed package versions section of the travis-ci output, Rmpfr is not listed. However, my DESCRIPTION file includes it as an import:
Imports:
Rmpfr,
dplyr,
magrittr
and Rmpfr is available on CRAN; my question is, how do I get travis-ci to install it?
The solution may be related to this previous question where the author had to include Java in their .travis.yml file. For Rmpfr, it looks like the MPFR C library is necessary. Is there a way to instruct travis to install this library in my .travis.yml file? Or am I barking up the wrong tree?
As you found out, you need the libmpfr-dev package to be installed. You can do this by adding
addons:
apt:
packages:
- libmpfr-dev
to your .travis.yml. See the documentation for reference.

How to force devtools to install packages in remotes

devtools package introduces a nice concept of adding dependancies not available in CRAN, into DESCRIPTION file (described in the vignette). However, I have not been able to figure out how to get it to install the dependancies automatically. The vignette linked above certainly hints that is possible and the install command certainly parses for the "remote" (got an error when they were not specified correctly), however, it only installed dependancies from CRAN. Anybody has ideas if there are some parameters I should specify to make the installation automatic?
Thusfar, I have tried install, install_bitbucket and install_local. install managed to download all the dependancies available in CRAN. install_bitbucket did the same and install_local just did not work at all.
The Remotes: field is used to tell devtools where to look for the packages that are listed in the standard Depends:, Imports: and Suggests:.
So make sure that you have the package listed in the appropriate standard field, and its source listed in Remotes. Then running the following should install these packages from the Remotes source:
devtools::install_deps()

Create an R package that depends on another R package located on GitHub

I am creating an R package on GitHub, LW1949, that depends on another R package on GitHub, jvamisc. When I try to install LW1949 using
require(devtools)
devtools::install_github("user/LW1949")
I get the message: Skipping 1 packages not available: jvamisc.
How can I point the import(jvamisc) part of the LW1949 package (in NAMESPACE) to Github instead of CRAN to find this dependency?
Surely this question has been asked and answered before, but I was not successful searching for it (perhaps because the search terms are so common - R, package, GitHub, etc.). I did stumble across Travis CI and Packrat, neither of which I've used. No idea if they would help. I would prefer as simple a fix as possible. (Wouldn't we all?)
I'm using R version 3.1.3 for Windows in R Studio Version 0.98.1103.
This question seems to have been answered quite recently, addressed in this issue of the devtools' github repository.
Package developer POV:
do:
usethis::use_package("jvamisc")
devtools::document()
to add the dependency in the Imports field of your DESCRIPTION file.
manually add a field "Remotes:" in the DESCRIPTION file, specifying where on github R should look for the package:
#in DESCRIPTION
Imports: ...,
jvamisc,
...
Remotes: JVAdams/jvamisc
End-user POV:
the end user has to have the latest development version of devtools (or at least the one corresponding to commit #f21ca3516c). You have to somehow 'force him' to update his devtools version (I guess just put this in the installation instructions... Can't think of a better way)
devtools::install_github(“hadley/devtools”, ref = “f21ca3516c”)
Restart the R Session on unload/reload the devtools package.
do the usual install_github:
require(devtools)
devtools::install_github("user/LW1949")
I guess this functionality will be added sooner or later to the CRAN version of devtools, so there will be no need for the user to fetch the dev version and he would go directly to step 3).
The steps and additional options are detailed in this vignette.
The actual solution seems to add in your DESCRIPTION file the line
Remotes: hadley/testthat
see the documentation of devtools :
# Git
Remotes: git::https://github.com/hadley/ggplot2.git
# Bitbucket
Remotes: bitbucket::sulab/mygene.r#default, dannavarro/lsr-package
# Bioconductor
Remotes: bioc::3.3/SummarizedExperiment#117513, bioc::release/Biobase
# SVN
Remotes: svn::https://github.com/hadley/stringr
# URL
Remotes: url::https://github.com/hadley/stringr/archive/master.zip
# Local
Remotes: local::/pkgs/testthat
# Gitorious
Remotes: gitorious::r-mpc-package/r-mpc-package

Resources