ytdl-org/youtube-dl · warning · XAttrUnavailableError

Couldn't find a tool to set the xattrs. Install either the p

Error message

Couldn't find a tool to set the xattrs. Install either the python 'xattr' module, or the 'xattr' binary.

What it means

Raised as XAttrUnavailableError by write_xattr in youtube_dl.utils on a non-Linux Unix platform (e.g. macOS or BSD) when no xattr backend is available: neither the python 'xattr'/'pyxattr' modules are importable nor a usable 'xattr'/'setfattr' CLI binary was found. It is the platform-specific sibling of the Linux message, naming the macOS-appropriate installation options.

Source

Thrown at youtube_dl/utils.py:6244

                    p = subprocess.Popen(
                        cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
                except EnvironmentError as e:
                    raise XAttrMetadataError(e.errno, e.strerror)
                stdout, stderr = process_communicate_or_kill(p)
                stderr = stderr.decode('utf-8', 'replace')
                if p.returncode != 0:
                    raise XAttrMetadataError(p.returncode, stderr)

            else:
                # On Unix, and can't find pyxattr, setfattr, or xattr.
                if sys.platform.startswith('linux'):
                    raise XAttrUnavailableError(
                        "Couldn't find a tool to set the xattrs. "
                        "Install either the python 'pyxattr' or 'xattr' "
                        "modules, or the GNU 'attr' package "
                        "(which contains the 'setfattr' tool).")
                else:
                    raise XAttrUnavailableError(
                        "Couldn't find a tool to set the xattrs. "
                        "Install either the python 'xattr' module, "
                        "or the 'xattr' binary.")


def random_birthday(year_field, month_field, day_field):
    start_date = datetime.date(1950, 1, 1)
    end_date = datetime.date(1995, 12, 31)
    offset = random.randint(0, (end_date - start_date).days)
    random_date = start_date + datetime.timedelta(offset)
    return {
        year_field: str(random_date.year),
        month_field: str(random_date.month),
        day_field: str(random_date.day),
    }


def clean_podcast_url(url):

View on GitHub (pinned to 956b8c5855)

Solutions

  1. Install the python xattr module: pip install xattr.
  2. Or install a compatible 'xattr' command-line binary (e.g. via Homebrew) and ensure it is on PATH.
  3. If xattr metadata is optional, remove --xattr-set-filesize from the invocation or config file.
  4. Guard the flag per-platform in wrapper scripts so macOS runs skip xattr writes.

Example fix

# before
youtube-dl --xattr-set-filesize URL  # on macOS → XAttrUnavailableError: Couldn't find a tool to set the xattrs...

# after
pip install xattr && youtube-dl --xattr-set-filesize URL
Defensive patterns

Strategy: try-catch

Validate before calling

import shutil, importlib.util, sys

def xattr_backend_available():
    if importlib.util.find_spec('xattr'):
        return True
    return bool(shutil.which('xattr') or shutil.which('setfattr'))

# on macOS/BSD, gate --xattr-set-filesize on xattr_backend_available()

Try / catch

from youtube_dl.utils import write_xattr, XAttrUnavailableError
try:
    write_xattr(path, key, value)
except XAttrUnavailableError as e:
    log.debug('xattr write skipped: %s', e)  # optional metadata; do not fail the job

Prevention

When it happens

Trigger: Running with --xattr-set-filesize (or calling write_xattr) on macOS/BSD where sys.platform does not start with 'linux', 'import xattr' fails, and the CLI fallbacks are unavailable, reaching the else branch's non-Linux raise.

Common situations: macOS with system python where xattr/pip module was never installed; Homebrew python environments without pip xattr; automation scripts assuming the backend exists across platforms.

Related errors


AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14). Data as JSON: /api/errors/5c18fc564ff44e19. Report an issue: GitHub.