Install jq JSON processor on Ubuntu 10.04
Asked Answered
E

5

101

Is there a way to install jq JSON processor on Ubuntu 10.04?

I Tried the usual sudo apt-get install jq but got the error E: Couldn't find package jq

Ecumenicalism answered 17/10, 2015 at 9:4 Comment(1)
what about without sudo permissions? my cluster doesn't let me install it and IT is fine if I install things on my own. – Sea
N
183

It is possible to perform sudo apt-get install jq however you need to inform the system where to find jq.

ℹ️ Note: Ubuntu 14+ users can skip to step 3! πŸŽ‰

Install

  1. Open your sources file in a text editor:

     sudo vim /etc/apt/sources.list
    
  2. Add the following line to the end of that file (note deb is not a command, more info):

    deb http://us.archive.ubuntu.com/ubuntu vivid main universe

  3. Then re-index apt-get so that it can find jq:

     sudo apt-get update
    
  4. Then do the normal install and you should be the proud new user of jq!

     sudo apt-get install jq
    

Test

Test it works! Try this to see it pretty print some example json

echo '{ "name":"John", "age":31, "city":"New York" }' | jq .

The result should appear like so in your terminal:

{
  "name": "John",
  "age": 31,
  "city": "New York"
}
Neapolitan answered 14/6, 2017 at 13:44 Comment(6)
On Ubuntu 14, I had to use old release source "deb old-releases.ubuntu.com/ubuntu vivid main universe" – Notochord
sudo apt-get update spit out some errors like "Some index files failed to download. They have been ignored, or old ones used instead." and sudo apt-get install jq still fails afterwards. How to go about fixing this (Ubuntu 17.04)? Automatic updates fail as well, telling me to check my network connection, but other internet access works fine (Git, Firefox, ...). It is running in a VM btw. – Colb
I was able to apt-get install jq just now on a Raspberry PI without altering sources.list – Freehand
Oh nice! Unfortunately Ubuntu 10.04 (and similar) users don't have it so easy though. – Neapolitan
I was getting E: Couldn't find package jq until I did sudo apt-get update. So for versions 14+ it's better to start from step 3. – Fibrillation
what about without sudo permissions? my cluster doesn't let me install it and IT is fine if I install things on my own. – Sea
U
44

Since Ubuntu 16.04LTS xenial you do not need to modify /etc/apt/sources.list, just run

sudo apt-get install jq

jq 1.5 is in the official Debian and Ubuntu repositories.

Unleavened answered 8/5, 2019 at 8:29 Comment(1)
what about without sudo permissions? my cluster doesn't let me install it and IT is fine if I install things on my own. – Sea
P
5

I think you're missing the repo: http://installion.co.uk/ubuntu/vivid/universe/j/jq/install/index.html

Polypus answered 9/11, 2015 at 13:33 Comment(0)
A
4

Download & build from source as described in https://stedolan.github.io/jq/download/, last section called "From source on Linux, OS X, Cygwin, and other POSIX-like operating systems".

Aloke answered 17/10, 2015 at 11:56 Comment(1)
I wasn't aware of existence of jq in a proper distribution channel as suggested in the other answers but since that is the case, one of the other answers should be the preferred/accepted one. – Aloke
S
0

If you don't have sudo permission do this:

#!/usr/bin/env bash

# conda activate jq_install_env

# - Install jq without sudo
# Clone the jq repository from GitHub
cd $HOME
git clone https://github.com/stedolan/jq.git $HOME/jq
cd $HOME/jq
git submodule update --init

# Compile jq from source
cd $HOME/jq
autoreconf -fi
./configure --with-oniguruma=builtin --disable-maintainer-mode --prefix=$HOME/.local
make -j8 && make check
make install
ls $HOME/.local
ls $HOME/.local/bin

# Add the directory where the jq binary file is located to your PATH environment variable
echo 'PATH=$PATH:~/.local/bin/' >> $HOME/.bashrc.lfs
export PATH=$PATH:~/.local/bin/
echo $PATH | tr ':' '\n'

# Reload your shell configuration file to update your PATH environment variable
source $HOME/.bashrc.lfs

# Verify that jq is installed and working
jq --version

reference: https://suzyahyah.github.io/misc/2020/03/31/jq-without-sudo.html

in case link dies:

Landing Page...
AboutCategoriesAdvisors
Recipe for building jq from source without admin(sudo) rights
Mar 31, 2020

This took me some time to install. Just putting it out there in case it helps someone.
Get the latest jq from github

git clone https://github.com/stedolan/jq.git

Update submodules (onigurama)

git submodule update --init

Copy missing auxiliary files

autoreconf -fi

Install into {YOUR_HOME_DIR} with onigurama (regex library)

./configure --with-oniguruma=builtin --disable-maintainer-mode --prefix={YOUR_HOME_DIR}.local

Check that we have all the dependencies downloaded and install

make -j8 && make check

make install

Finally, add this to your ~/.bashrc and to call jq from anywhere. Remember to >source ~/.bashrc and you should be good to go.

export PATH=$PATH:~/.local/bin/

Β« The Sigmoid in Regression, Neural Network Activation and LSTM GatesA minimum keystroke (py)Debugger for Lazy ML/DS people who don't IDE Β»
Quality means doing it right when no one is looking - Henry Ford
 suzyahyah
 suzyahyah
The best time to plant a tree was 20 years ago. The second best time is now. - Japanese proverb

Since October 2017
Sea answered 17/10, 2015 at 9:4 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.