yt-dlp: On MAC: On the same call, when providing the update and arguments to download the video, the download fails

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Please make sure the question is worded well enough to be understood

by calling yt-dlp in mac, I got this issue and upfront to open a bug report, i wanna be sure.

This happens only on MAC. On Windows and Linux it works fine. On the same call, when providing the update and arguments to download the video, the download fails example

yt-dlp --update-to master -S vcodec:h264,res,acodec:aac <URL_of_the_video> -P "F:/Videos/" -o "My Title.mp4"

  • it checks for the update
  • if founded: – it updates itself then – it stops without re-run itself and going ahead to execute the arguments given to download the video.
  • if not founded: – it goes ahead normally by downloading the video as requested

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 55 (15 by maintainers)

Most upvoted comments

@pms967 is correct, and to expand on what was said: yt-dlp (the zipimport executable product of make) does not unpack its contents to /tmp, like how yt-dlp_macos (the pyinstaller-bundled executable) needs to do. The needed unpacking is known to be the cause of the slowdown (again, to be discussed in #10425), and I wouldn’t be surprised it’s the cause of the post-update restart failure as well.

To recenter on the original problem as stated by @Grub4K, one more info : the problem does not happen when using a checkout of the github project. On my machine, if I git clone the repository, cd into it, make it and launch :

./yt-dlp --update-to master "https://www.youtube.com/watch?v=9pZUokleIf0" -o "test.mp4" -v

Then yt-dlp restarts correctly after update and starts the download, when the yt-dlp_macos binary provided in the releases doesn’t.

According to his tests - in Windows - it looks like the control returns to the calling LUA script as soon as yt-dlp write something “on screen”, thus obviously before it has completed whatever operation(s) it was instructed to do.

This is being tracked in a separate issue as well: #11355

I asked a couple questions to try to investigate the issue but didn’t get an answer for either of them.

Please keep the discussion in this issue on-topic or else it will be locked

Allow application from is set to “App Store & Known Developers” on my machine. I am on macOS Sequoia 15.1.

There have been occasional reports of insanely long startup times on macOS, likely due to gatekeeper. I was never able to reproduce these either.

Thank you for the explanation. However even with these steps I can not replicate on my machine. I also do not get asked for authorization by macos. Potentially this is some security mechanism by Apple, but until another dev can reproduce this will be difficult to debug and fix.

@BenTalagan

Just running make in a fresh checkout directory, and launching the produced executable (it looks like it starts with ‘#!/usr/bin/env python3’ and then a zip made of python script files is appended). I don’t build yt-dlp_macos (I don’t know how), and the produced executable is smaller by far.

Yeah, because (differently from yt-dlp_macos) this contains only the Python code of yt-dlp, and rely on a Python interpreter already installed on the system. Of course it won’t run if a viable version of Python3 can’t be found.

@pms967 is it enough quick under Linux? i mean is it acceptable?

there’s no perceivable delay or slowness WRT the same command run manually from the command line. But that’s expected, since the delay is a specific Mac-only problem.

But the main problem seems to be completely unrelated to LUA, let alone Reaper.

I think this is true, this discussion is derailing into something thats not related to the original issue anymore. Please keep it on track with the issue at hand, the MacOS build not restarting properly after auto-updating. The additional posts makes it hard to properly find information related to the issue.

PS: Maybe discussion on the discord or some private channel would be more appropriate for solving the lua issue. Also for windows you should not use start at all if possible.


To summarize: The MacOS build exits instead of restarting itself, which results in an error code of 247.

Current open investigation points:

  • Any MacOS security policy blocking the file?
    • After running failing the command, check “System Settings/Preferences > Security & Privacy”. Did any file actually try to launch (as can be seen in that list) but was blocked?
  • What does exit code 247 stand for? Only thing I could find was related to OOM errors, nothing in other, related topics
  • Eventually a minimal reproduction case, possibly using a simple pyinstaller python file downloaded from the internet

@pms967 thanks for the suggestion ! Unfortunately, I think @tormyvancool’s requirements were to be able to do everything in one call for other reasons (yt-dlp is called inside a lua script which uses os.execute and the way yt-dlp outputs the logs does trigger some problems, but here it’s not my part anymore 😃 )

@seproDev regarding the authorizations, maybe you’ve authorized your system to launch applications coming from any developer ?

This can be checked in Settings > Privacy & Security > Allow apps from anywhere

Normally, this option cannot be enabled through the UI, it is hidden and is triggered by :

sudo spctl --master-disable

Standard users generally don’t have this option on, but only trust the app store and “identified developers”.

Anyway, I’ve changed this parameter on my own machine and remade the test. It effectively disables the authorization popup (so we spare the auth step), but the rest of the problem is the same, on the first launch yt-dlp updates itself, says it’s going to restart to perform the download of the video, but it’s not restarting. (The last log line is the one starting with “[debug] Restarting: etc”). The command needs to be launched again for that.

For info right now I’m testing on Ventura 13.6.3.

Hi I’m jumping in the discussion because it’s not productive. What Tormy is actually posting are the results of a common debugging session, he’s not working under macos but asks me to launch some commands and as posted the results here so the information is not formatted correctly and hardly understandable.

Regarding the yt-dlp ./yt-dlp_macos stuff, the first part is just the prompt of my shell (it was the name of the folder where the yt-dlp_macos binary was located).

Please, make abstraction of what’s been posted precedently and follow these simple steps. From a macos terminal :

  • Download yt-dlp_macos from the github release page
  • Go to the Downloads directory (or the one where you stored the binary)
  • chmod +x yt-dlp_macos
  • Launch the following command :

./yt-dlp_macos --update-to master -S vcodec:h264,res,acodec:aac "https://www.youtube.com/watch?v=9pZUokleIf0" -o "test.mp4" -v

(at this point macos asks for authorizations, that you should give from the preferences panel)

Re-launch the command. You will get the following output :

[debug] Command-line config: ['--update-to', 'master', '-S', 'vcodec:h264,res,acodec:aac', 'https://www.youtube.com/watch?v=9pZUokleIf0', '-o', 'test.mp4', '-v']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2024.11.04 from yt-dlp/yt-dlp [197d0b03b] (darwin_exe)
[debug] Python 3.12.7 (CPython x86_64 64bit) - macOS-13.6.3-x86_64-i386-64bit (OpenSSL 3.0.15 3 Sep 2024)
[debug] exe versions: ffmpeg 7.0.1 (setts), ffprobe 7.0.1, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.21.0, brotli-1.1.0, certifi-2024.08.30, curl_cffi-0.7.1, mutagen-1.47.0, requests-2.32.3, sqlite3-3.45.3, urllib3-2.2.3, websockets-13.1
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets, curl_cffi
[debug] Loaded 1838 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-master-builds/releases/latest
[debug] Downloading _update_spec from https://github.com/yt-dlp/yt-dlp-master-builds/releases/latest/download/_update_spec
[debug] Downloading SHA2-256SUMS from https://github.com/yt-dlp/yt-dlp-master-builds/releases/download/2024.11.04.003339/SHA2-256SUMS
Current version: stable@2024.11.04 from yt-dlp/yt-dlp
Latest version: master@2024.11.04.003339 from yt-dlp/yt-dlp-master-builds
Current Build Hash: 14829d7aea733e991b3ff8d098dbf5ec3bf5825b6fc6bf62edee62362c9704e7
Updating to master@2024.11.04.003339 from yt-dlp/yt-dlp-master-builds ...
[debug] Downloading yt-dlp_macos from https://github.com/yt-dlp/yt-dlp-master-builds/releases/download/2024.11.04.003339/yt-dlp_macos
Updated yt-dlp to master@2024.11.04.003339 from yt-dlp/yt-dlp-master-builds
[debug] Restarting: ./yt-dlp_macos --update-to master -S vcodec:h264,res,acodec:aac 'https://www.youtube.com/watch?v=9pZUokleIf0' -o test.mp4 -v

It stops here, yt-dlp_macos is now up to date, but the restart is not effective. The command needs to be launched again manually to launch the download, while yt-dlp_macos says it’s restarting.

Basically, that’s what Tormy is complaining about.