How to Install jq 1.5 on RHEL 6.5 When Yum Package is Unavailable


28 views

When attempting to compile jq 1.5 from source on RHEL 6.5, many developers encounter the error regarding Autoconf version requirements. The key error message reveals:

configure.ac:10: error: Autoconf version 2.64 or higher is required
autom4te: /usr/bin/m4 failed with exit status: 63

First, verify your current Autoconf version:

autoconf --version

If it's below 2.64, you'll need to upgrade the development tools:

sudo yum install -y automake autoconf libtool make gcc

Since RHEL 6.5's repositories contain outdated packages, we'll need to build from source:

wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz
tar -xzf jq-1.5.tar.gz
cd jq-1.5

Install prerequisite libraries:

sudo yum install -y bison flex oniguruma-devel

For older systems, you might need to compile oniguruma manually:

wget https://github.com/kkos/oniguruma/releases/download/v5.9.6/onig-5.9.6.tar.gz
tar -xzf onig-5.9.6.tar.gz
cd onig-5.9.6
./configure && make && sudo make install

If compiling fails, try the pre-built binary approach:

wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 -O jq
chmod +x jq
sudo mv jq /usr/local/bin/

After installation, test jq functionality:

echo '{"test": "value"}' | jq '.test'

Expected output should be:

"value"

When attempting to install jq from source on RHEL 6.5, you're hitting a fundamental dependency conflict. The system's default autoconf version (2.63) is too old for jq's requirements (2.64+). Here's why this happens:

$ autoreconf -i
configure.ac:14: warning: macro AM_PROG_AR' not found in library
configure.ac:10: error: Autoconf version 2.64 or higher is required
autom4te: /usr/bin/m4 failed with exit status: 63

You have three viable approaches:

1. Binary Installation (Recommended)

The simplest method is using pre-built binaries:

wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
chmod +x jq-linux64
sudo mv jq-linux64 /usr/local/bin/jq

2. Manual Dependency Upgrade

For source compilation:

# Install updated autoconf
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar xzf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure --prefix=/usr/local
make
sudo make install

# Then install jq
git clone https://github.com/stedolan/jq.git
cd jq
autoreconf -fi
./configure --disable-maintainer-mode
make
sudo make install

3. Docker Alternative

For containerized environments:

docker run -v $(pwd):/data -it stedolan/jq:latest jq '.field' /data/file.json

After installation, test functionality:

$ echo '{"key":"value"}' | jq '.key'
"value"

Common jq operations in RHEL environments:

# Filter AWS instance metadata
curl -s http://169.254.169.254/latest/meta-data/ | jq '.'

# Process Kubernetes output
kubectl get pods -o json | jq '.items[].metadata.name'

# Transform CSV to JSON (via Miller then jq)
mlr --c2j cat data.csv | jq '.records[]'