"jq": executable file not found in $PATH

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: “jq”: executable file not found in $PATH

| username: 末0_0想

[TiDB Usage Environment] Production Environment
[TiDB Version] v6.50
[Reproduction Path]
When I use tiup ctl:v6.5.0 pd -u -i and enter the mode, I use region --jq=".regions[] | {id: .id, peer_stores: [.peers[].store_id]}" to view the region distribution, but I get the following error:

exec: "jq": executable file not found in $PATH
write |1: file already closed

How should I handle this?

Using the following command also doesn’t work.

export PD_ADDR= && tiup ctl:v6.5.0 pd -u -i
| username: TiDBer_jYQINSnf | Original post link

jq is a command. Is it possible that your image doesn’t have the jq command? I’m not familiar with tiup, just for your reference.

| username: zhanggame1 | Original post link

Try removing the jp parameter first.

| username: 裤衩儿飞上天 | Original post link

jq needs to be installed separately, you can search for it on Baidu.

| username: 秋季番Oo | Original post link

jq is a separate command that usually needs to be installed additionally.

| username: xingzhenxiang | Original post link

You need to install it yourself

| username: ljluestc | Original post link

The error message you encountered indicates that the jq command cannot be found in the $PATH environment variable, which is necessary for executing the tiup ctl command with the --jq option. jq is a lightweight and flexible command-line JSON processor used in this context to filter and manipulate JSON data.

To resolve this issue, you have two options:

  1. Manually install jq: You can install jq on the machine where you are running the tiup ctl command. The installation method varies depending on the operating system. For example, on Linux, you can use package managers like apt, yum, or brew to install jq. On Windows, you can download the executable from the official jq website and place it in a directory included in the system’s %PATH%.

  2. Use alternative methods to process JSON output: If installing jq is not feasible or desirable, you can consider using alternative methods to process the JSON output. For example, you can redirect the output of the tiup ctl command to a file and then use scripting languages like Python or JavaScript to process the JSON data. These languages provide built-in JSON parsing and manipulation capabilities.