4

so in my project, there are serveral pre-commit hooks to make sure our codes meet team standard, but whenever i try to commit changes, there is always an error saying executable was not found. usually, i first assumed there must be some problem with PATH environment variable value, but it's the only acutal git commit command that causes the issue.

yunu@LAPTOP-8FK6RMJ8:/mnt/d/Projects/xyz/idl$ pre-commit
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed
yamllint.............................................(no files to check)Skipped
ensure buf...............................................................Passed
buf check lint...........................................................Passed
buf check breaking.......................................................Passed
yunu@LAPTOP-8FK6RMJ8:/mnt/d/Projects/xyz/idl$ git commit
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed
yamllint.............................................(no files to check)Skipped
ensure buf...............................................................Failed
- hook id: ensure-buf
- exit code: 1

Executable `task` not found

buf check lint...........................................................Failed
- hook id: buf-lint
- exit code: 1

Executable `buf` not found

buf check breaking.......................................................Failed
- hook id: buf-breaking
- exit code: 1

Executable `buf` not found

and i can run the commands which were said to be not found right after this.
i can see that bash identifies these commands just fine.

yunu@LAPTOP-8FK6RMJ8:/mnt/d/Projects/xyz/idl$ buf
Usage:
  buf [command]

Available Commands:
  check           Run lint or breaking change checks.
  experimental    Experimental commands. Unstable and will likely change.
  help            Help about any command
  image           Work with Images and FileDescriptorSets.
  ls-files        List all Protobuf files for the input location.
  protoc          High-performance protoc replacement.

Flags:
  -h, --help                help for buf
      --log-format string   The log format [text,color,json]. (default "color")
      --log-level string    The log level [debug,info,warn,error]. (default "info")
      --timeout duration    The duration until timing out. (default 2m0s)
  -v, --version             version for buf

Use "buf [command] --help" for more information about a command.
yunu@LAPTOP-8FK6RMJ8:/mnt/d/Projects/xyz/idl$

so what would be the issue? does git command use different kind of PATH of its own?

i'm running this on ubuntu wsl on windows 10.

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
yunu
  • 81
  • 4
  • Can you run `.git/hooks/pre-commit` without any issue ? – LeGEC Aug 25 '20 at 05:22
  • thanks for the help, it results same problem as it happend in git commit, error message shows multiple commands were not found. was i running wrong command whole this time? – yunu Aug 25 '20 at 05:28
  • Can it work if `buf` and `task` are replaced with their full paths in `pre-commit`? – ElpieKay Aug 25 '20 at 06:29

3 Answers3

4

it was solved after i removed .git/hooks/pre-commit and run pre-commit install again. Now i can use git commit command without trouble.

yunu
  • 81
  • 4
0

For me, all I had to do was restart PyCharm

WurmD
  • 1,231
  • 5
  • 21
  • 42
0

I was getting the same error over and over on VScode; I ended up using hadolint dockerfile instead

so in my pre-commit-config.yaml I have

  - repo: local
    hooks:
    - id: hadolint
      name: hadolint
      entry: hadolint/hadolint:v2.12.1-beta hadolint --ignore DL3008 --no-color
      language: docker_image
      types: [file, dockerfile]
Areza
  • 5,623
  • 7
  • 48
  • 79