diff --git a/beets/ui/commands/config.py b/beets/ui/commands/config.py index 15d5713246..bd52aed9e5 100644 --- a/beets/ui/commands/config.py +++ b/beets/ui/commands/config.py @@ -50,17 +50,20 @@ def config_edit(cli_options): """ path = cli_options.config or config.user_config_path() editor = editor_command() + + if not editor: + raise ui.UserError( + "Please set the VISUAL or EDITOR environment variable to edit" + " configuration." + ) try: if not os.path.isfile(path): open(path, "w+").close() interactive_open([path], editor) + except FileNotFoundError: + raise ui.UserError(f"Editor {editor!r} not found.") except OSError as exc: - message = f"Could not edit configuration: {exc}" - if not editor: - message += ( - ". Please set the VISUAL (or EDITOR) environment variable" - ) - raise ui.UserError(message) + raise ui.UserError(f"Could not edit configuration: {exc}") config_cmd = ui.Subcommand("config", help="show or edit the user configuration") diff --git a/docs/changelog.rst b/docs/changelog.rst index e759c9df0c..80ed763bf9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -94,6 +94,8 @@ Bug fixes backends, such as ``mp3gain``. :bug:`2946` - :doc:`plugins/mbpseudo`: Fix crash due to missing ``artist_credit`` field in the MusicBrainz API response. :bug:`6339` +- :ref:`config-cmd`: Improved error message when user-configured editor does not + exist. :bug:`6176` .. For plugin developers