0

jq command not found after adding jq executable

installing jq on git bash

My usecase is more similar with above shared references. I tried to execute a hook that needs to parse a json file. When hook gets executed it throws bash: jq:command not found error. So. I downloaded jq-win64.exe file and copied it to /usr/bin in Git folder. Then from git-bash I run export PATH=$PATH:"/C/Program Files/Git/usr/bin/jq-win64.exe" command and there is no error but when I checked jq --version command it still shows bash: jq:command not found error

Am I missing something? I even tried in windows cmd but is of no use. Hope someone can help me. Thanks in advance!!!

torek
  • 448,244
  • 59
  • 642
  • 775
Vasantha
  • 47
  • 5
  • Note that git-bash is not part of Git. It is merely a port of bash *to* Windows, and is typically included *with* Git-for-Windows, because Git needs a POSIX-compatible shell, and the port of bash was available. – torek Dec 09 '22 at 07:01
  • @torek The Git folder which I referred here is the one that appeared in C drive when I installed git-bash.exec on my system. – Vasantha Dec 09 '22 at 07:31
  • You can install git-bash by itself, or you can install Git-for-Windows which also installs git-bash. It sounds like you did the latter. Git isn't relevant! Just git-bash and jq matter here. (The fact that Git is invoking bash for you, via your hooks, just makes bash matter; the fact that your bash script invokes jq makes jq matter. You can run the hook without using Git.) – torek Dec 09 '22 at 09:18

1 Answers1

1

PATH contains directories. That means what you should do:

  1. Rename jq-win64.exe to jq.exe or just jq. (e.g. cp ~/Downloads/jq-win64.exe /usr/bin/jq).
  2. You don't have to export your path, /usr/bin is already part of it.

If you didn't rename the file to jq (or jq.exe), then you would have to run it as jq-win64 in your console.

You could also put the binary into ~/bin folder, which should be part of PATH too. If it isn't, you can add it. Then you don't need to mess with your global binaries folder.

knittl
  • 246,190
  • 53
  • 318
  • 364