Skip to content

Pre-commit hooks for readme don't work on Windows #2167

@christopherkenny

Description

@christopherkenny

Create a package on Windows with:

devtools::create('somepackage')

which uses an Rmd-based readme:

usethis::use_readme_rmd()

This creates a pre-commit hook. Now, to push to GitHub, you are required on Windows to either delete the file named .git/hooks/pre-commit or force commits to go with --no-verify.

On a Mac, you can just make sure you run:

devtools::build_readme()

I believe that is the intended behavior. However, on Windows, you always see the error:

error: cannot spawn .git/hooks/pre-commit: No such file or directory

Looking through my old notes, I've seen this problem since (at least) March 2021. (Sorry, I probably should have made this issue much sooner.) I can replicate this on 3 different Windows machines.

But, this makes sense, as it's written for linux/macos machines, as the pre-hook commit starts with:

#!/bin/bash

To be clear, Windows users can set up non-standard workarounds to make this type of syntax work and may opt into that.

Can the readme pre-hook commit be opt-in, rather than default? This is especially important for people who collaborate across platforms or develop packages across them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions