-3

I am getting the below commit error in my Mac OS after updating to the latest version. Tried restarting VS Code and also tried to use terminal and same error. Until git add . step it works fine. Only the commit command is not working fine. What could be the issue?

enter image description here

 git commit -m "Commit message"
.git/hooks/pre-commit: line 15: python: command not found
.git/hooks/pre-commit: line 16: python: command not found
anthony sottile
  • 61,815
  • 15
  • 148
  • 207
Krishnamurthy
  • 139
  • 2
  • 8

3 Answers3

6

The MacOs 12.3 update removed the built-in python 2.7 client.

Options:

  • install python 2.7 manually, for example from here
  • look into the pre-commit file: maybe it can be updated to use python3 (which would need to be installed then of course)
GhostCat
  • 137,827
  • 25
  • 176
  • 248
1

The following code in the .git/hooks/pre-commit file throws python: command not found

else
  # Linux / Mac
  python ${HOOKS_DIR}/detect_remote
  python ${HOOKS_DIR}/detect_secret
fi%  

The solution for me is as easy as update python to python3 in the pre-commit file since I have python3 installed on my Mac.

BabyPanda
  • 1,562
  • 12
  • 18
-4

I found the issue. I removed the pre-commit file from the .git directory and that fixed the issue.

Krishnamurthy
  • 139
  • 2
  • 8
  • 2
    Note: this is not the issue, this is not a fix. This is just: ignoring the underlying problem. Commit hooks exist so that specific code gets executed prior you doing the commit. What happens here is that the latest MacOs update REMOVED python 2.7 (so the python binary you have in your path), and therefore that code cant be executed any more. So, the real answers could be: to change the commit hook code to use python3, or to manually install some python, ... plenty of options. Each one better than just removing that file. – GhostCat Mar 30 '22 at 07:15
  • This is an actively harmful answer. Deleting the `pre-commit` file without knowing why it is there, and how it got there, encourages developers to make decisions in isolation that may negatively impact a project and its collaborators. – Patrick Johnmeyer Nov 18 '22 at 17:30