72

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

Ste-3PO
  • 915
  • 1
  • 8
  • 18

4 Answers4

139

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"
}
Stefan Collier
  • 3,688
  • 1
  • 23
  • 31
  • 1
    On Ubuntu 14, I had to use old release source "deb http://old-releases.ubuntu.com/ubuntu vivid main universe" – vaichidrewar Feb 20 '18 at 23:55
  • 2
    `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. – CodeManX Apr 25 '18 at 12:34
  • I was able to `apt-get install jq` just now on a Raspberry PI without altering `sources.list` – mehov Aug 15 '18 at 06:21
  • Oh nice! Unfortunately Ubuntu 10.04 (and similar) users don't have it so easy though. – Stefan Collier Aug 15 '18 at 08:53
  • 1
    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. – artifex Feb 09 '21 at 15:54
35

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.

Nik
  • 2,427
  • 2
  • 22
  • 24
4

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

Somaiah Kumbera
  • 6,442
  • 3
  • 37
  • 41
3

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".

Hans Z.
  • 46,131
  • 10
  • 91
  • 111
  • 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. – Hans Z. Nov 03 '17 at 12:44