Skip to content

/bin/sh not on Windows #602

Closed
Closed

Description

@adam-grant-hendry

Description

The pre-commit scripts test and format rely on /bin/sh, which does not exist on Windows (at least the path). This is a non-portable shebang, which can be fixed by using #!/usr/bin/env sh instead.

Steps to reproduce

  1. Follow the Contributing steps to:
    (a) Fork the repo, install dependencies through poetry, and setup the pre-commit hooks
  2. Run pre-commit run --all

Current behavior

On Windows, the pre-commit hooks format and linter and test fail with the error message Executable '/bin/sh' not found.

Desired behavior

The pre-commit hooks are able to run the provided shell scripts.

Screenshots

image

Environment

Commitizen Version: 2.35.0
Python Version: 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]
Operating System: Windows

Activity

  1. adam-grant-hendry commented on Oct 14, 2022

    @adam-grant-hendry
    ContributorAuthor

    Substituting the portable shebang works. However, pytest reports many failing tests and errors (completely unrelated to the changes). The following report was generated with pytest-html:

    pytest_report.zip

  2. Lee-W commented on Oct 17, 2022

    @Lee-W
    Member

    Hi @adam-grant-hendry , thanks for your report. The html seems to miss some style and barely readable now. Could you guide me through on how to view it correctly? Or could you please share a few example on what you're testing and what's not working even with shebang?

  3. jenstroeger commented on Oct 17, 2022

    @jenstroeger
    Contributor

    @adam-grant-hendry are you on vanilla Windows, or do you use WSL or some other *NIX port on Windows?

    I ask because both format and test scripts are sh (e.g. bash and co) scripts that assume an appropriate environment.

  4. adam-grant-hendry commented on Oct 17, 2022

    @adam-grant-hendry
    ContributorAuthor

    The html seems to miss some style and barely readable now. Could you guide me through on how to view it correctly?

    I forgot to zip the CSS assets with it, my mistake. I updated the link, so please try downloading and unzipping again. You should see a folder assets with a file style.css in addition to pytest_report.html that will help it render properly.

    I ask because both format and test scripts are sh (e.g. bash and co) scripts that assume an appropriate environment.

    I use vanilla Windows. The fact the test scripts require that environment is not specified in the Contributing Guide. Rather than switching over to WSL or Cygwin/MSYS, I changed the shebang to a portable variant. My users use Windows, so I develop on Windows (it's easier for me to find problems and help them that way).

    Regardless, the greater problem is your Windows CI doesn't run. Even if I switched to WSL or Cygwin/MSYS, I have no confidence that commitizen will work for my PowerShell users.

    Is commitizen intended only to be used by bash/sh users? That's going to cut off a lot of end users from using it, especially if they're in a restricted environment (e.g. corporate setting) that does not permit them to use these shells.

  5. Lee-W commented on Oct 20, 2022

    @Lee-W
    Member

    I just saw your test output. Could you please install https://gnupg.org/download/ and see how it works? It seems the doc is outdated. Before we add it to the doc, let's verify whether installing gpg fix it


    Is commitizen intended only to be used by bash/sh users? T

    Ideally, no. We hope this project can be used by all users.

  6. adam-grant-hendry commented on Oct 20, 2022

    @adam-grant-hendry
    ContributorAuthor

    I just saw your test output. Could you please install https://gnupg.org/download/ and see how it works? It seems the doc is outdated. Before we add it to the doc, let's verify whether installing gpg fix it

    I installed that and also tested out gpg.exe that ships with Git for Windows (it resides in C:\Program Files\Git\usr\bin. Both work well.

    All tests are now passing in PR #605, so I was able to fix all the errors previously experienced on Windows. Please kindly re-review it at your earliest convenience.

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions