Installation

pkoppstein edited this page Mar 6, 2018 · 25 revisions

The "Download" page for jq at http://stedolan.github.io/jq/download/ also includes instructions for installing jq from source. 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.

Below are some "recipes", such as using Homebrew, or building from source.

Mac OSX

With Homebrew

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

From github

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:

$ brew install oniguruma
$ mkdir github		
$ cd github		
$ git clone https://github.com/stedolan/jq.git		
$ cd jq
$ autoreconf -i --disable-maintainer-mode
$ ./configure
$ 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:

$ brew install oniguruma
$ mkdir github		
$ cd github		
$ git clone https://github.com/stedolan/jq.git		
$ cd jq; autoreconf -i ; ./configure ; make 

Notes:

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

With MacPorts

jq version 1.5 has been available from MacPorts since August 21, 2015. Once MacPorts has been installed, run: sudo port install jq

Or build from source

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) Not 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

Windows with choco

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.

Windows using 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.

With Docker

Directly install the release binary with Dockerfile:

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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.