audible-cli icon indicating copy to clipboard operation
audible-cli copied to clipboard

`audible manage config edit` fails on Windows: TypeError: 'WindowsPath' object is not iterable

Open Whissi opened this issue 2 months ago • 1 comments

I manually created C:\Users\<user>\AppData\Local\audible. With an empty config.toml or with the example content from the README file, audible manage config edit will fail with

(audible-cli) C:\Users\MyUser\AppData\Local\audible-cli>audible manage config edit
Uncaught Exception
Traceback (most recent call last):
  File "C:\Users\MyUser\AppData\Local\audible-cli\Lib\site-packages\audible_cli\cli.py", line 62, in main
    sys.exit(cli(*args, **kwargs))
             ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\MyUser\AppData\Local\audible-cli\Lib\site-packages\click\core.py", line 1462, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\MyUser\AppData\Local\audible-cli\Lib\site-packages\click\core.py", line 1383, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Users\MyUser\AppData\Local\audible-cli\Lib\site-packages\click\core.py", line 1850, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\MyUser\AppData\Local\audible-cli\Lib\site-packages\click\core.py", line 1850, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\MyUser\AppData\Local\audible-cli\Lib\site-packages\click\core.py", line 1850, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\MyUser\AppData\Local\audible-cli\Lib\site-packages\click\core.py", line 1246, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\MyUser\AppData\Local\audible-cli\Lib\site-packages\click\core.py", line 814, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\MyUser\AppData\Local\audible-cli\Lib\site-packages\click\decorators.py", line 93, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\MyUser\AppData\Local\audible-cli\Lib\site-packages\click\core.py", line 814, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\MyUser\AppData\Local\audible-cli\Lib\site-packages\audible_cli\cmds\cmd_manage.py", line 41, in config_editor
    click.edit(filename=session.config.filename)
  File "C:\Users\MyUser\AppData\Local\audible-cli\Lib\site-packages\click\termui.py", line 772, in edit
    ed.edit_files(filenames=filename)
  File "C:\Users\MyUser\AppData\Local\audible-cli\Lib\site-packages\click\_termui_impl.py", line 599, in edit_files
    exc_filename = " ".join(f'"{filename}"' for filename in filenames)
                                                            ^^^^^^^^^
TypeError: 'WindowsPath' object is not iterable

Tested on Windows 11 with Python 3.12.10.

Whissi avatar Oct 15 '25 04:10 Whissi

🐛 Root Cause & Temporary Workaround

Thanks for reporting this!
The issue is caused by a change in Click ≥ 8.2, where the internal call to Editor.edit_files() now expects an iterable of strings (or a single string), rather than a plain Path object.

Passing a pathlib.Path directly — as in:

click.edit(filename=session.config.filename)

now triggers:

TypeError: 'WindowsPath' object is not iterable

because WindowsPath or any other pathlib.Path object is not iterable.


✅ Root Cause

  • Click ≥ 8.2 treats filename as a sequence of files (Iterable[str]) or as a file (str). Providing a pathlib.Path object is not possible anymore.
  • pathlib.Path objects are path-like but not iterable, causing a TypeError.

🔧 Temporary Workaround

Until the next release includes the fix, you can patch your local installation by editing
audible_cli/cmds/cmd_manage.py
and replacing the problematic line:

click.edit(filename=session.config.filename)

with:

import os

path = session.config.filename
click.edit(filename=os.fspath(path))

This ensures:

  • the file exists before opening, and
  • Click receives a list of string paths, which works on all platforms and Click versions.

🧩 Next Steps

A permanent fix using this approach will be included in an upcoming patch release.
Thanks again for catching this regression and for your patience!

mkb79 avatar Oct 15 '25 08:10 mkb79