Could Not Open File Lol. Json: Permission Denied Using Jq?

I am facing some kind of permission issue here. I am able to read a file with cat, make changes to it using nano but for some reason, jq is having permission issues. Here is what I am facing:

msp@coolpad:~/projects/lol$ jq .name lol.json
jq: error: Could not open file lol.json: Permission denied

On checking permissions, this is what I get:

msp@coolpad:~/projects/lol$ ls -l
total 4
-rw-rw-r-- 1 msp msp   0 Sep 27 04:04 lol-domains.txt
-rwxrwxrwx 1 msp msp 593 Sep 27 04:38 lol.json

As you can see, I have tried giving it 777 permission, still it's showing Permission denied. I know this is not a good idea to set 777 permission and I fully intend to change it back to 664 once the issue is resolved. Anyhelp would be appriciated.

Update 1: I have tried re-installing jq from snap but still, it doesn't solve the problem.

Update 2: Output of cat lol.json

msp@coolpad:~$ cat lol.json
{"name":"lol"}

Update 3: Output of echo '{"name":"lol"}' | jq .name

msp@coolpad:~$ echo '{"name":"lol"}' | jq .name
"lol"

Update 4: One work-around that poped up in comments:

cat lol.json | jq .name

13

1 Answer

sudo snap remove jq
sudo apt install jq

Never install command line tools with snap without --classic. This error is indented behavior.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest