Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty runtime config file produces exception #551

tyhoff opened this issue Jul 6, 2018 · 2 comments

Empty runtime config file produces exception #551

tyhoff opened this issue Jul 6, 2018 · 2 comments


Copy link

tyhoff commented Jul 6, 2018


When running Invoke with an empty runtime config file, the following exception is hit.

$ inv --list
Traceback (most recent call last):
  File "/Users/username/miniconda2/envs/env/bin/inv", line 11, in <module>
  File "/Users/username/miniconda2/envs/env/lib/python2.7/site-packages/invoke/", line 313, in run
  File "/Users/username/miniconda2/envs/env/lib/python2.7/site-packages/invoke/", line 243, in create_config
    self.config = self.config_class()
  File "/Users/username/miniconda2/envs/env/lib/python2.7/site-packages/invoke/", line 641, in __init__
  File "/Users/username/miniconda2/envs/env/lib/python2.7/site-packages/invoke/", line 927, in merge
    self._merge_file('user', "Per-user")
  File "/Users/username/miniconda2/envs/env/lib/python2.7/site-packages/invoke/", line 951, in _merge_file
    merge_dicts(self._config, data)
  File "/Users/username/miniconda2/envs/env/lib/python2.7/site-packages/invoke/", line 1170, in merge_dicts
    for key, value in updates.items():
AttributeError: 'NoneType' object has no attribute 'items'

Desired Result

Passing in a valid, empty .yml file should not throw an exception.

Steps to reproduce

  1. Create a new directory
  2. Create a simple file
from invoke import task, Collection, Config

def hello(ctx):
    print("Hello {}".format(
  1. Create an empty ~/.invoke.yaml file
  2. Run invoke --list


I think it's reasonable to just return early if the dict being passed in is None.

diff --git a/invoke/ b/invoke/
index 6d13ac08..84501133 100644
--- a/invoke/
+++ b/invoke/
@@ -1174,6 +1174,9 @@ def merge_dicts(base, updates):

     .. versionadded:: 1.0
+    if not updates:
+        return base
     # TODO: for chrissakes just make it return instead of mutating?
     for key, value in updates.items():
         # Dict values whose keys also exist in 'base' -> recurse

Let me know if you need any more information or want me to throw up a commit!

Copy link

Feel like I ran into this myself recently too 🙃 thanks for the detailed report! I agree that it ought to just no-op instead of exploding.

Copy link

Actually, this is (perhaps unsurprisingly) an old problem and so there's an existing issue already - #270! Rolling into that. I'm just gonna fix it now either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants