27.2 Github Actions

This section is very incomplete, but I’m gonna start writing reminders to myself:

  • Github Actions won’t find new packages that I recently added to the notes unless the renv.lock file is updated. So gotta use renv::snapshot() and commit the renv.lock file to the repo after adding a new package.
  • If pubtheme has been updated and re-installed on my machine, I need to reinstall it via devtools::install_github("bmacGTPM/pubtheme"). If I install it from the pubtheme package R project Build -> Install, then I think renv won’t be able to automatically detect where the packages comes from. The renv.lock will say source unknown. It’s not reproducible on another machine. If, however, I install it from Github, which is reproducible on another machine, then renv will auto-detect the source and all will be well.
  • When updating packages, I should remember to install the binary versions when the source version is more recent. Github Actions wasn’t able to find these. So I had to reinstall the binary versions. If the project has been activated, check which packages are binary and which are source with renv::status(). If it hasn’t been activated (like the first time I dealt with this), I installed a package that gave an error in Github Actions, reran Github Actions, see which package errored, install the binary version, and repeat.
  • It seems like the Windows repo and Linux repo don’t have the same package versions. For plotly, I downloaded 4.10.4, but version 4.10.3 was listed here

I installed an earlier version using this

devtools::install_version("plotly", 
version = "4.10.3", 
repos = "http://cran.us.r-project.org")
  • terra was failing on Github Actions. I tried this to reinstall all packages that depend on terra
## Check for dependencies, and reinstall all packages
d1 = revdep('terra')
d2 = installed.packages()
re.install = d1[d1 %in% d2[,'Package']] ## d2 is matrix, can't use $
if (length(re.install) > 0) {
  install.packages(re.install, dependencies=TRUE)
}


## Check for dependencies, and reinstall all packages
d1 = revdep('units')
d2 = installed.packages()
re.install = d1[d1 %in% d2[,'Package']] ## d2 is matrix, can't use $
if (length(re.install) > 0) {
  install.packages(re.install, dependencies=TRUE)
}

## then use code like this
devtools::install_version('tidycensus', version = '1.1')
devtools::install_version('sf', version = '1.0-2')
devtools::install_version('units', version = '0.7-2')
devtools::install_version('raster', version = "3.4-13")
  • I had issues with units, which is needed for sf, which is needed for tidycensus. So I removed tidycensus for now.
    • The error says libudunits2.so.0: cannot open shared object file: No such file or directory. This is related to an Ubuntu library, and NOT the R library ubunits2
    • I added sudo apt-get install libudunits2-dev to the yaml file and that worked. See .github/bookdown.yaml. Then I added libproj-dev and libgdal-dev because I got similar errors to the above, in particular, xxxxxxx.xx.x: cannot open shared object file: No such file or directory
  • I had issues with terra, which is needed for raster, which is needed for leaflet. But terra wasn’t needed for the earlier version 3.4-13 of raster that I was using. So installed that version. Didn’t work. Tried downloading the dev version of terra using install.packages('terra', repos='https://rspatial.r-universe.dev'). Did this work?
  • Temporary fix: remove 50*.Rmd files, which require leaflet, from the main folder into the R folder