SteinarV
SteinarV

Reputation: 105

Problem with the command-line JSON processor JQ in Windows 10, 64 bit

I have downloaded the program jq-win64.exe from 'https://stedolan.github.io/jq/' and installed the program in a folder C:\Program Files\jq\ on my computer. I have also added the PATH to the program to the end of the systemvariable string in Windows 10 : . . . ;C:\Program Files\curl\;C:\Program Files\jq\

In one terminal window in Visual Studio Code I am running a server. In another terminal window I am trying to execute the command curl -s localhost:3000 | jq

Terminal window 1: C:\Users\SteinarV\PROFF_JAVASCRIPT\PROJECT\smartHouse

node server.js API running on port 3000

Terminal window 2: C:\Users\SteinarV\PROFF_JAVASCRIPT\PROJECT\smartHouse>curl -s localhost:3000 | jq

'jq' is not recognized as an internal or external command, operable program or batch file

... and do not understand why jq is not recognized. Can someone help ?

Upvotes: 7

Views: 23131

Answers (1)

Weeble
Weeble

Reputation: 17940

I have downloaded the program jq-win64.exe from 'https://stedolan.github.io/jq/' and installed the program in a folder C:\Program Files\jq\ on my computer.

As you have indicated, you have a file called jq-win64.exe but you are trying to execute the command jq. You either need to rename the file to jq.exe or you need to use the command jq-win64.

For a detailed explanation of how Windows finds and executes a program in your path when you enter a command, see The Windows NT Command Shell: Command Search Sequence. Specifically:

...The shell now searches each directory specified by the PATH environment variable, in the order listed, for an executable file matching the command name. If a match is found, the external command (the executable file) executes...

...If the command name does not include a file extension, the shell adds the extensions listed in the PATHEXT environment variable, one by one, and searches the directory for that file name. Note that the shell tries all possible file extensions in a specific directory before moving on to search the next directory (if there is one)...


You indicate in the comments the same error persists even when the filenames match. Note that each running program has its own set of environment variables, and these aren't updated by global changes. You need to close and reopen cmd.exe windows after making a global change. See also Adding directory to path environment variable in windows. You can use the path command to verify whether a particular terminal session has inherited the PATH variable you defined, thus narrowing your problem.


You indicate that the problem still persists. You need to use the tools available to you to narrow it down further:

Try running the program with its full path:

"C:\Program Files\jq\jq-win64.exe" --help

This will confirm that the program is present where you think it is and can be run from the terminal.

Try running the program with no path and its extension:

jq-win64.exe --help

If this works but running the program without an extension doesn't, you might have set PATHEXT to something that doesn't include ".EXE".

Try setting the path explicitly in the terminal to contain only the program directory and nothing else, then run it with its full extension:

set PATH=C:\Program Files\jq
jq-win64.exe --help

(Note that after this test you'll need to close the terminal window and start a new one to reset the path.)

If this works, perhaps you have a mismatch in your path.

Upvotes: 10

Related Questions