-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Installation
Downloads are also available from https://github.com/stedolan/jq/releases, and the FAQ includes supplementary information about installing jq.
The above-mentioned resources should be regarded as the primary points of reference regarding installation of jq.
The asdf "version manager" ("one version manager to rule them all" - https://asdf-vm.com/#/core-manage-asdf) can also be used for installation in Linux and MacOS environments.
See also https://repology.org/metapackage/jq/versions
Below are some "recipes", such as using Homebrew, or building from source.
Note: If make
fails because of ruby or python, try running configure
with the --disable-docs
command-line option.
- Zero Install
- MacOS
- Build from source
- Windows with choco
- Windows using Appveyor
- Windows 10 using homebrew
- With Docker
A convenient way to install one or more versions of jq on Linux, Windows or MacOS is to use 0install ("Zero Install").
Assuming 0install itself has already been installed and that ~/bin/jq does not yet exist, the most recent version of jq known to 0install can be installed by running:
0install add jq https://apps.0install.net/utils/jq.xml
To add a particular version, say jq 1.4, you could use the incantation:
0install add --version=1.4 jq1.4 https://apps.0install.net/utils/jq.xml
There are various ways to install 0install itself. For example, at a bash or similar prompt, you could run:
curl -O https://get.0install.net/0install.sh && chmod +x 0install.sh
./0install.sh
and then follow the directions. For further details about which versions of jq are available via 0install, enter the above jq.xml URL in your browser. See also https://roscidus.com/0mirror/feeds/https/apps.0install.net/utils%23jq.xml/feed.html
First, check that homebrew is available, e.g. by typing: which brew
(For details about installing homebrew, see http://brew.sh)
If you just want to install the homebrew version of jq:
$ brew install jq
or for the most recent version:
brew install --HEAD jq
The following instructions assume you want to install jq from the "master" branch,
and that you wish to include regex support. If you do not wish to include regex support
(that is, if you wish to build jq without oniguruma), then add the "-with-oniguruma=no" option
to the configure
command.
(a) If you do not need to install jq in "maintainer mode", then you could proceed as follows:
## Part 1:
# Ensure autoconf, automake and libtool are available, e.g. by running:
$ brew install autoconf automake libtool
# You may also wish to install oniguruma at this point, e.g. by running: brew import oniguruma
## Part 2:
$ mkdir github
$ cd github
$ git clone https://github.com/stedolan/jq.git
$ cd jq
## Part 3 -
## Option 1: use the "builtin" oniguruma
cd modules/oniguruma
autoreconf -fi
cd ../..
autoreconf -i
./configure --with-oniguruma=builtin
make
## Option 2: use an alternative oniguruma
autoreconf -i
./configure --disable-maintainer-mode
make
(b) If you want to install jq in "maintainer mode", then you will need bison version 3, which can be made available by running:
$ brew install bison
# Ensure that this bison has priority, e.g. perhaps by running:
# ln -s /usr/local/bin/bison ~/bin/bison
Next, use brew
to install or upgrade oniguruma
, autoconf
, automake
and libtool
as required, e.g.:
$ brew install oniguruma autoconf automake libtool
Finally:
$ mkdir github
$ cd github
$ git clone https://github.com/stedolan/jq.git
$ cd jq; autoreconf -i ; ./configure ; make
Notes:
(1) If the autoreconf -i
command fails with error messages such as the following:
/usr/local/bin/glibtoolize: line 401: /usr/local/Library/ENV/4.3/sed: No such file or directory
then either try running brew upgrade libtool
, or create a link from the directory in the error messages to /usr/bin/sed
(2) If you get error messages involving pipenv
and if you do not need the documentation to be "built", then add the --disable-docs
flag to ./configure, e.g.
./configure --disable-docs
jq version 1.5 has been available from MacPorts since August 21, 2015. Once MacPorts has been installed, run: sudo port install jq
The following, which is courtesy of @textarcana, should be regarded as illustrative. jq can be installed without using sudo
, and the installation of RVM dependencies can be skipped if there is no need to create the documentation locally.
Install Bison 3:
cd /tmp
wget http://ftp.gnu.org/gnu/bison/bison-3.0.3.tar.gz
tar -xvzf bison-3.0.3.tar.gz
cd bison-3.0.3
sudo port install m4
./configure --prefix=/usr/local/bison
sudo make install
sudo ln -s /usr/local/bison/bin/bison /usr/bin/bison
Install Dependencies (RVM, for docs)
Note that as of February 26, 2019, ruby is no longer a dependency for building jq from "master"; python is used instead. If make
fails because of python, run configure
with the --disable-docs
command-line option.
Note also that curl | bash
is a best practice...
cd ~/jq/docs
curl -L https://get.rvm.io | bash -s stable --ruby=1.9.3
cd docs
bundle install
Install Dependencies (Oniguruma)
wget https://web.archive.org/web/20150803013327/http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.6.tar.gz
tar -xf onig-5.9.6.tar.gz
cd onig-5.9.6
./configure
make
sudo make install
Build jq Note: to cross-compile for a different OS/platform (e.g., Windows) see Cross-compile.
cd ~/jq
autoreconf -i
./configure
make -j8
sudo make install
If you have "choco" (https://chocolatey.org), the following should install a pre-compiled binary:
choco install jq
On one machine, the above command installed jq at /cygdrive/c/ProgramData/chocolatey/bin/jq
Note that jq version 1.5 has a bug on Windows that causes it to crash when given file names over 38 characters in length. Later builds with a fix for this bug can be obtained from Appveyor.
A wide range of versions of jq are available as jq.exe files from Appveyor. If interested, first visit the following page to determine which version you want: https://ci.appveyor.com/project/stedolan/jq/history
Then click on the version you want, or click on “LATEST BUILD”.
Next, depending on whether you want a 32-bit or 64-bit version, click on one of the links under "JOB NAME", and then click on the "ARTIFACTS" link.
In brief:
- Install bash for Windows 10
- Install homebrew for Linux (http://brew.sh)
- In a bash window, run:
brew install jq
ENV JQ_VERSION='1.5'
RUN wget --no-check-certificate https://raw.githubusercontent.com/stedolan/jq/master/sig/jq-release.key -O /tmp/jq-release.key && \
wget --no-check-certificate https://raw.githubusercontent.com/stedolan/jq/master/sig/v${JQ_VERSION}/jq-linux64.asc -O /tmp/jq-linux64.asc && \
wget --no-check-certificate https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-linux64 -O /tmp/jq-linux64 && \
gpg --import /tmp/jq-release.key && \
gpg --verify /tmp/jq-linux64.asc /tmp/jq-linux64 && \
cp /tmp/jq-linux64 /usr/bin/jq && \
chmod +x /usr/bin/jq && \
rm -f /tmp/jq-release.key && \
rm -f /tmp/jq-linux64.asc && \
rm -f /tmp/jq-linux64
The perl5 binding author has made it possible to compile jq from source using CMake. Both jq executable and static/dynamic library can be made via following steps:
- Install CMake latest executable binary on your host, add cmake command into PATH.
- Download and extract jq latest source code into a local folder - $jq-version/.
- [not required for jq version >= 1.6] Download and extract oniguruma latest source code into $jq-version/modules/oniguruma. This is exact the same folder structure as in jq version 1.6 where oniguruma source is bundled together.
- Clone/Download https://github.com/dxma/perl5-alien-libjq and copy all the files within the jq subfolder into $jq-version/ directory. They are all required things for CMake.
- Execute cmake command with needed options. Nearly all options have the same name as in autoconf. A sample call can be found within the perl5 package - https://github.com/dxma/perl5-alien-libjq/blob/master/alienfile#L34
Note the CMake support is still work in progress: such as MSVC support on Windows, jq document generation and other internal dev options. Check the latest copy of https://github.com/dxma/perl5-alien-libjq/blob/master/jq/CMakeLists.txt for 'TODO' and 'NOTE'.
- Home
- FAQ
- jq Language Description
- Cookbook
- Modules
- Parsing Expression Grammars
- Docs for Oniguruma Regular Expressions (RE.txt)
- Advanced Topics
- Guide for Contributors
- How To
- C API
- jq Internals
- Tips
- Development