1

Problem Description

I'm having trouble making commits, when I try to make a commit with the command, for example:

$ git commit -m "add readme"
pre-commit not found. Install pre-commit with the command pip3 install --user pre-commit or follow the steps on official documentation: https://pre-commit.com /#install

Following the steps described in the pre-commit installation documentation I installed by the command:

$ pip install pre-commit

However when I trigger the command the following error occurs:

$ pre-commit --version
bash: pre-commit: command not found

My attempt fails, so I've tried some other solutions for this but they didn't work.

Export bash:

I already tried this solution described that would be to export my ~./bashrc with the command: source ~/.profile but the following error happens:

bash:/Users/pvieira/.profile: No such file or directory

Install using homebrew:

This results in the same error that occurs when manually installing by pip above.

James Risner
  • 5,451
  • 11
  • 25
  • 47
Pierre Vieira
  • 2,252
  • 4
  • 21
  • 41
  • 1
    pre-commit would not produce that output so it's something custom that you or your company has set up – anthony sottile Jun 25 '22 at 04:06
  • 1
    Are you using a virtual environment? Maybe pre-commit was installed only inside of a virtual env, but you are doing git commit outside of a virtualenv. – Gino Mempin Jun 25 '22 at 04:34

4 Answers4

4

I was able to solve the problem by simply restarting the terminal.

Pierre Vieira
  • 2,252
  • 4
  • 21
  • 41
0

command not found

This error generally means that your shell could not find the an matching executable file in their hash or that the file is not longer located at the previous location. The shell creates a hash of all programs in the PATH environment variable when it loads.

Depending on your shell you can refresh their hash by running hash or rehash.

The reason reloading your shell or terminal fixes the issue is because it, in effect, creates a new hash. Along the same lines, restarting the computer also happens to recreate a new hash.

James Risner
  • 5,451
  • 11
  • 25
  • 47
0

I have used MacOS. I solved this problem installed pre-commit by brew install pre-commit

-1

I solved this problem by restarting my ubuntu system

alonegame
  • 49
  • 4