Permission denied to a file in ~/.cache directory

When I set an output file in the home directory, the following curl command works. But when I use ~/.cache/mydir, it returns "Permission error".

$ ls -al ~/.cache/tera
drwxrwxr-x 2 shinichi shinichi 4096 Jul 28 09:04 .
drwx------ 16 shinichi shinichi 4096 Jul 27 20:52 ..
-rw-rw-r-- 1 shinichi shinichi 0 Jul 28 09:04 radio_searches.json
$ curl -X POST -d tag=smooth -o $HOME/.cache/tera/radio_searches.json % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- 0:00:04 --:--:-- 0Warning: Failed to create the file
Warning: /home/shinichi/.cache/tera/radio_searches.json: Permission denied
100 10 0 0 100 10 0 1 0:00:10 0:00:05 0:00:05 2
curl: (23) Failure writing output to destination

Why I can output to a file in the home directory, but not in the ~/.cache/mydir.

5

1 Answer

I use the Snap when I installed curl.

The Snap ‘home’ interface permits access only to non-hidden files and directories in a user’s /home.

sudo snap remove gh
sudo rm -r ~/snap/gh

I used apt to install curl and it is working now.

sudo apt install curl

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like