Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.cache - Permission issue #180

Closed
LukePWilkins opened this issue Sep 5, 2022 · 11 comments
Closed

.cache - Permission issue #180

LukePWilkins opened this issue Sep 5, 2022 · 11 comments

Comments

@LukePWilkins
Copy link

When downloading a YT video, I receive the following lines in the log file
File "/usr/local/lib/python3.8/site-packages/yt_dlp/cache.py", line 44, in store
today at 10:02:19 AM os.makedirs(os.path.dirname(fn))
today at 10:02:19 AM File "/usr/local/lib/python3.8/os.py", line 213, in makedirs
today at 10:02:19 AM makedirs(head, exist_ok=exist_ok)
today at 10:02:19 AM File "/usr/local/lib/python3.8/os.py", line 213, in makedirs
today at 10:02:19 AM makedirs(head, exist_ok=exist_ok)
today at 10:02:19 AM File "/usr/local/lib/python3.8/os.py", line 223, in makedirs
today at 10:02:19 AM mkdir(name, mode)
today at 10:02:19 AMPermissionError: [Errno 13] Permission denied: '/.cache'

Unsure where to set the cache location to ensure permissions are correct

@LukePWilkins LukePWilkins changed the title .cahce - Permission issue .cache - Permission issue Sep 5, 2022
@PikuZheng
Copy link
Contributor

I believe it is related to the user. If you are running it on Synology, find the administrator user's gid & pid and set it

@alexta69
Copy link
Owner

alexta69 commented Sep 6, 2022

Are you sure you haven't changed anything in the docker image / python files? The code as it is disables the cache directory (https://github.com/alexta69/metube/blob/master/app/ytdl.py#L80), and indeed nobody else is getting this behavior (even though metube runs without root privileges, so it really can't create /.cache).

@LukePWilkins
Copy link
Author

Interesting. I expected it to be user related. I will double check the user.
Thanks for the replies.

@alexta69 alexta69 closed this as completed Oct 5, 2022
@3guboff
Copy link

3guboff commented Oct 25, 2022

Are you sure you haven't changed anything in the docker image / python files? The code as it is disables the cache directory (https://github.com/alexta69/metube/blob/master/app/ytdl.py#L80), and indeed nobody else is getting this behavior (even though metube runs without root privileges, so it really can't create /.cache).

The problem exists, to reproduce, use some 4k video from youture:

metube    | WARNING: Writing cache to '/.cache/yt-dlp/youtube-nsig/4bbf8bdb.json' failed: Traceback (most recent call last):
metube    |   File "/usr/local/lib/python3.8/site-packages/yt_dlp/cache.py", line 44, in store
metube    |     os.makedirs(os.path.dirname(fn))
metube    |   File "/usr/local/lib/python3.8/os.py", line 213, in makedirs
metube    |     makedirs(head, exist_ok=exist_ok)
metube    |   File "/usr/local/lib/python3.8/os.py", line 223, in makedirs
metube    |     mkdir(name, mode)
metube    | PermissionError: [Errno 13] Permission denied: '/.cache/yt-dlp'
metube    |
metube    | INFO:ytdl:downloading XXX
metube    | ======== Running on http://0.0.0.0:8081 ========
metube    | (Press CTRL+C to quit)
metube    | INFO:aiohttp.access:172.20.0.1 [25/Oct/2022:18:38:59 +0000] "POST /add HTTP/1.1" 200 264 "https://metube.my.site/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36"
metube    | INFO:ytdl:waiting for item to download```

@PikuZheng
Copy link
Contributor

Confirmed that the current latest version has this problem @alexta69

@alexta69
Copy link
Owner

Very strange. We're disabling the cache, so it's not supposed to it. In some videos it tries to use cache anyway? Can you provide a sample URL?

@3guboff
Copy link

3guboff commented Oct 30, 2022

Very strange. We're disabling the cache, so it's not supposed to it. In some videos it tries to use cache anyway? Can you provide a sample URL?

Any video, for example

@alexta69
Copy link
Owner

alexta69 commented Nov 4, 2022

Yes, I can see it happening too. Looked a bit into it, and it looks like a yt-dlp bug: we're passing cachedir=False, and there's a check for that in their Cache object, but apparently there's a Cache somewhere that's initialized without the yt-dlp options, so it continues with the default values.

In any case, I see the video downloads fine despite the error. So I guess it's not that urgent to fix. If someone has some time to try to trace the call and find the Cache object that misbehaves, I suppose a fix can be submitted to yt-dlp.

@1RandomDev
Copy link
Contributor

But why are you guys trying to disable the caching feature of yt-dlp? Why not just create the missing directory in the container with RUN mkdir /.cache && chmod 777 /.cache or of course you can also mount it to the host to make the cache survive updates?

@The-May
Copy link

The-May commented Apr 10, 2023

@alexta69 Any updates on this?
Stll getting PermissionError: [Errno 13] Permission denied: '/.cache'
D

My docker-compose is following:

version: "3"
services:
  metube:
    image: ghcr.io/alexta69/metube
    container_name: metube
    restart: unless-stopped
    ports:
      - "8081:8081"
    volumes:
      - /etc/youtube_metube:/downloads

It doesnt matter which directory I use.
Can a temporary env variable be set?

@1RandomDev
Copy link
Contributor

1RandomDev commented Apr 10, 2023

You can just add - /etc/youtube_metube/cache:/.cache to the volumes and make sure that the directory has file mode 777.

@alexta69 I fixed the error inside the container in #247. Maybe you want to take a look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants