pre-commit-hook-yamlfmt icon indicating copy to clipboard operation
pre-commit-hook-yamlfmt copied to clipboard

Executable ... not found when running pre-commit

Open CelestialGuru opened this issue 3 years ago • 9 comments

Issue

When I run pre-commit run --all-files I get the following:

Trim Trailing Whitespace.................................................Passed
Fix End of Files.........................................................Passed
Check Yaml...............................................................Passed
Check for added large files..............................................Passed
yamllint.................................................................Passed
Format YAML files........................................................Failed
- hook id: yamlfmt
- exit code: 1

Executable `C:UsersUser.cachepre-commitrepoolie1bxepy_env-python3.9Scriptspython.EXE` not found

It looks like somwhere somehow the / characters are being stripped because I was able to find this:

C:\Users\User\.cache\pre-commit\repoolie1bxe\py_env-python3.9\Scripts\python.exe

I even tried renaming .../python.exe to .../python.EXE but that didn't seem to matter.

Config

My .pre-commit-config.yaml file:

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
  - repo: 'https://github.com/pre-commit/pre-commit-hooks'
    rev: v3.2.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-added-large-files

  - repo: https://github.com/adrienverge/yamllint.git
    rev: v1.21.0
    hooks:
      - id: yamllint
        args: [--format, parsable, --strict, --config-file, config.yamllint]

  - repo: 'https://github.com/jumanjihouse/pre-commit-hook-yamlfmt'
    rev: 0.1.0
    hooks:
      - id: yamlfmt

Environment

I am using Windows 10 Pro I have activated a virtual environment, but both the virtual environment and the global one have pre-commit installed. My python version is 3.9.5

CelestialGuru avatar Jul 02 '21 17:07 CelestialGuru

I'm experiencing the same issue. My system info:

OS: Microsoft Windows Server 2016 Standard Python: 3.7.2

andfranklin avatar Sep 03 '21 20:09 andfranklin

The issue seems to be with how the yamlfmt script is deployed. It may be best to move the main logic to a module and export an entry point for pre-commit. That seems to be how the main pre-commit-hooks repo does it.

linuxdaemon avatar Sep 05 '21 05:09 linuxdaemon

Issue

When I run pre-commit run --all-files I get the following:

Trim Trailing Whitespace.................................................Passed
Fix End of Files.........................................................Passed
Check Yaml...............................................................Passed
Check for added large files..............................................Passed
yamllint.................................................................Passed
Format YAML files........................................................Failed
- hook id: yamlfmt
- exit code: 1

Executable `C:UsersUser.cachepre-commitrepoolie1bxepy_env-python3.9Scriptspython.EXE` not found

It looks like somwhere somehow the / characters are being stripped because I was able to find this:

C:\Users\User\.cache\pre-commit\repoolie1bxe\py_env-python3.9\Scripts\python.exe

I even tried renaming .../python.exe to .../python.EXE but that didn't seem to matter.

Config

My .pre-commit-config.yaml file:

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
  - repo: 'https://github.com/pre-commit/pre-commit-hooks'
    rev: v3.2.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-added-large-files

  - repo: https://github.com/adrienverge/yamllint.git
    rev: v1.21.0
    hooks:
      - id: yamllint
        args: [--format, parsable, --strict, --config-file, config.yamllint]

  - repo: 'https://github.com/jumanjihouse/pre-commit-hook-yamlfmt'
    rev: 0.1.0
    hooks:
      - id: yamlfmt

Environment

I am using Windows 10 Pro I have activated a virtual environment, but both the virtual environment and the global one have pre-commit installed. My python version is 3.9.5

I am facing the same issue. And I have same config as yours

pritom007 avatar Sep 13 '21 03:09 pritom007

It might be useful for someone to know. I found a fix in this PR and connected it correctly in this way: .pre-commit-config.yaml

   - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
     rev: 71af8556bfcf12745fdfdb3ed57b6698b444f58c
     hooks:
       - id: yamlfmt
         args: [--mapping, '2', --sequence, '4', --offset, '2']

vyach-vasiliev avatar Mar 13 '23 20:03 vyach-vasiliev

Classic backslashes in path on Windows not being escaped :) Got this too.

Avasam avatar Mar 25 '23 05:03 Avasam

Hey, I encountered the same issue and wanted to ask, if there is a fix for the removal of the backslashes?

larskinder avatar Apr 28 '23 08:04 larskinder

Still no fix?

cedric-aebi avatar Aug 03 '23 11:08 cedric-aebi

Same error in Windows 10

tahq69 avatar Oct 27 '23 10:10 tahq69

I ended up using pre-commit in WSL

danielwiegand avatar Nov 27 '23 13:11 danielwiegand