Github Workflows and Windows Line Endings

Workflows executed via Github Actions are a great way to automate checking changes you make to an R package as you get access to all three major platforms (Windows, Mac OSX, Linux). I’ve been using them with the rhdf5filters package, which isn’t yet in Bioconductor and so doesn’t get to benefit from the multi-platform checking provided there.

However, the run of R CMD check was consistently failing on Windows with the warning:

* checking line endings in shell scripts ... WARNING
Found the following shell script(s) with CR or CRLF line endings:
  configure.ac
Non-Windows OSes require LF line endings.

This was super annoying as the error did not show up either during local testing, nor on the Github workflows running on other operating systems. I tried quite a number of strategies for trying to pin this behaviour down, including running dos2unix, changing execute permissions on the file, modifying the style of comments, and re-writing it using R, none of which made any difference.

With the help of AlanBOCallaghan it turns out the default behaviour of git on Windows is to automatically change line endings to the Windows style CRLF. The first step of my workflow was to clone the git repository, and hence, regardless of what had been committed, the line endings of configure.ac (and presumably all the other source files) really would be CRLF.

The solution was to add the following step as the first item in my workflow, before the git checkout (you can view the exact position here. This setting turns off the conversion behaviour and will leave line endings as they are in the repository.

      - name: Configure git
        run: git config --global core.autocrlf false

The workflow then completed successfully.

Updated: