From 12295376eb0a185a46675cf91d0e74069b1f8070 Mon Sep 17 00:00:00 2001 From: Tom Jaspers Date: Tue, 7 Jul 2015 22:56:02 +0100 Subject: [PATCH] Create empty user config file if it does not exist Running `beet config -e` with a non-existing configuration file does not always work (e.g., OSX uses `open` by default, which requires the file to exist). This could occur during e.g. initial setup. Resolve #1480 --- beets/ui/commands.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 76473e678..bbdbbcf96 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -1482,11 +1482,13 @@ def config_func(lib, opts, args): def config_edit(): """Open a program to edit the user configuration. + An empty config file is created if no existing config file exists. """ path = config.user_config_path() - editor = os.environ.get('EDITOR') try: + if not os.path.isfile(path): + open(path, 'w+').close() util.interactive_open(path, editor) except OSError as exc: message = "Could not edit configuration: {0}".format(exc)