Skip to content

/bin/sh not on Windows #602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
adam-grant-hendry opened this issue Oct 14, 2022 · 6 comments
Closed

/bin/sh not on Windows #602

adam-grant-hendry opened this issue Oct 14, 2022 · 6 comments

Comments

@adam-grant-hendry
Copy link
Contributor

adam-grant-hendry commented Oct 14, 2022

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

@adam-grant-hendry
Copy link
Contributor Author

adam-grant-hendry commented Oct 14, 2022

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

@Lee-W
Copy link
Member

Lee-W commented Oct 17, 2022

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?

@jenstroeger
Copy link
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.

@adam-grant-hendry
Copy link
Contributor Author

adam-grant-hendry commented Oct 17, 2022

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.

@Lee-W
Copy link
Member

Lee-W commented Oct 20, 2022

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.

@adam-grant-hendry
Copy link
Contributor Author

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
Projects
None yet
Development

No branches or pull requests

3 participants