deadc0de6 / dotdrop

Save your dotfiles once, deploy them everywhere
https://dotdrop.readthedocs.io
GNU General Public License v3.0
1.79k stars 105 forks source link

[bug] #378

Closed acourtneybrown closed 1 year ago

acourtneybrown commented 1 year ago

Dotdrop version (and git commit if run from source): v1.12.7 Using dotdrop: Homebrew

Describe the bug

The change requiring a dotfiles property in each profile appear to fail if the profile is only included elsewhere, but does not include files of include other profiles.

Steps to Reproduce

In my dotdrop config.yaml file, including the dotfiles property (currently commented out here) causes the following error:

$ dotdrop compare
[ERR] config error: 'NoneType' object is not iterable

When the dotfiles property is commented out,

$ dotdrop compare
[WARN] "dotfiles" entry is mandatory and was not present in profile "personal".
     _       _      _
  __| | ___ | |_ __| |_ __ ___  _ __
 / _` |/ _ \| __/ _` | '__/ _ \| '_ |
 \__,_|\___/ \__\__,_|_|  \___/| .__/  v1.12.7
                               |_|

24 dotfile(s) compared.

Expected behavior

With the dotfiles property in the profile, I would expect the following output:

$ dotdrop compare
     _       _      _
  __| | ___ | |_ __| |_ __ ___  _ __
 / _` |/ _ \| __/ _` | '__/ _ \| '_ |
 \__,_|\___/ \__\__,_|_|  \___/| .__/  v1.12.7
                               |_|

24 dotfile(s) compared.

Additional information

The relevant part of the config file

...
profiles:
    exhubber:
    dotfiles:
    include:
      - shared
      - personal
  personal:
    # dotfiles:
    variables:
      personal: true
  shared:
    dotfiles:
      - d_bin
...

Dotdrop's execution with the debug logs (--verbose)

$ dotdrop compare --verbose ...
[DEBUG][dotdrop.options.__init__] #################################################
[DEBUG][dotdrop.options.__init__] #################### DOTDROP ####################
[DEBUG][dotdrop.options.__init__] #################################################
[DEBUG][dotdrop.options.__init__] version: 1.12.7
[DEBUG][dotdrop.options.__init__] command: /usr/local/bin/dotdrop --cfg /Users/adambrown/.dotfiles/dotfiles/../config.yaml compare --verbose
[DEBUG][dotdrop.options.__init__] config file: /Users/adambrown/.dotfiles/dotfiles/../config.yaml
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] START of config parsing
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] reloading: False
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] profile: exhubber
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] included profiles: 
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] ----------dump:/Users/adambrown/.dotfiles/config.yaml----------
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] 
config:
  backup: true
  create: true
  force_chmod: true
  link_dotfile_default: link
  link_on_import: link
  dotpath: dotfiles
  upignore:
    - .DS_Store
    - .localized
  cmpignore:
    - .DS_Store
    - .localized
dotfiles:
  d_bin:
    src: bin
    dst: ~/bin
profiles:
  exhubber:
    dotfiles:
    include:
      - shared
      - personal
  exhubber.local:
    dotfiles:
    include:
      - exhubber
  exhubber.notcharlie.com:
    dotfiles:
    include:
      - exhubber
  personal:
    dotfiles:
    variables:
      personal: true
  shared:
    dotfiles:
      - d_bin
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] ----------end:/Users/adambrown/.dotfiles/config.yaml----------
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] format: yaml
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] normalizing relative to cfg: dotfiles -> /Users/adambrown/.dotfiles/dotfiles
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] settings block::
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "backup": True
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "banner": True
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "create": True
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "dotpath": /Users/adambrown/.dotfiles/dotfiles
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "ignoreempty": False
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "keepdot": False
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "link_dotfile_default": link
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "link_on_import": link
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "longkey": False
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "showdiff": False
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "workdir": /Users/adambrown/.config/dotdrop
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "minversion": None
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "diff_command": diff -r -u {0} {1}
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "template_dotfile_default": True
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "ignore_missing_in_dotdrop": False
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "force_chmod": True
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "chmod_on_import": False
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "check_version": False
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "clear_workdir": False
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "compare_workdir": False
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "key_prefix": True
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "key_separator": _
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "default_actions": []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "import_actions": []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "import_configs": []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "import_variables": []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "cmpignore": ['.DS_Store', '.localized']
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "upignore": ['.DS_Store', '.localized']
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "instignore": []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "impignore": []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "func_file": []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "filter_file": []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] variables block:
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] dynvariables block:
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] current variables defined:
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "profile": exhubber
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "_dotdrop_dotpath": /Users/adambrown/.dotfiles/dotfiles
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "_dotdrop_cfgpath": /Users/adambrown/.dotfiles/config.yaml
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "_dotdrop_workdir": /Users/adambrown/.config/dotdrop
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] profiles block:
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "exhubber"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * dotfiles: "None"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * include: "['shared', 'personal']"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "exhubber.local"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * dotfiles: "None"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * include: "['exhubber']"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "exhubber.notcharlie.com"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * dotfiles: "None"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * include: "['exhubber']"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "personal"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * dotfiles: "None"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * variables: "ordereddict([('personal', True)])"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "shared"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * dotfiles: "['d_bin']"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] included variables from shared: {}
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] included variables from personal: {'personal': True}
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] included dynvariables from shared: {}
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] included dynvariables from personal: {}
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] variables defined (after template dict):
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "profile": exhubber
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "_dotdrop_dotpath": /Users/adambrown/.dotfiles/dotfiles
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "_dotdrop_cfgpath": /Users/adambrown/.dotfiles/config.yaml
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "_dotdrop_workdir": /Users/adambrown/.config/dotdrop
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "personal": True
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] variables defined (after template include):
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "profile": exhubber
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "_dotdrop_dotpath": /Users/adambrown/.dotfiles/dotfiles
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "_dotdrop_cfgpath": /Users/adambrown/.dotfiles/config.yaml
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "_dotdrop_workdir": /Users/adambrown/.config/dotdrop
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "personal": True
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] dotfiles block:
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]   - "d_bin"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * src: "bin"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * dst: "~/bin"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * link: "link"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * ignoreempty: "False"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml]     * template: "True"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] actions block:
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] trans_r block:
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] trans_w block:
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber includes shared,personal
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber dotfiles before include: []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber actions before include: []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] resolving includes "exhubber" <- "shared"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] recursively resolving includes for profile "shared"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] Merging dotfiles exhubber <- shared: [] <- ['d_bin']
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] Merging actions exhubber <- shared: [] <- []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] resolving includes "exhubber" <- "personal"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] recursively resolving includes for profile "personal"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] Merging dotfiles exhubber <- personal: ['d_bin'] <- []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] Merging actions exhubber <- personal: [] <- []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber dotfiles after include: ['d_bin']
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber actions after include: []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber.local includes exhubber
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber.local dotfiles before include: []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber.local actions before include: []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] resolving includes "exhubber.local" <- "exhubber"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] recursively resolving includes for profile "exhubber"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] Merging dotfiles exhubber.local <- exhubber: [] <- ['d_bin']
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] Merging actions exhubber.local <- exhubber: [] <- []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber.local dotfiles after include: ['d_bin']
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber.local actions after include: []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber.notcharlie.com includes exhubber
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber.notcharlie.com dotfiles before include: []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber.notcharlie.com actions before include: []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] resolving includes "exhubber.notcharlie.com" <- "exhubber"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] recursively resolving includes for profile "exhubber"
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] Merging dotfiles exhubber.notcharlie.com <- exhubber: [] <- ['d_bin']
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] Merging actions exhubber.notcharlie.com <- exhubber: [] <- []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber.notcharlie.com dotfiles after include: ['d_bin']
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] exhubber.notcharlie.com actions after include: []
[DEBUG][dotdrop.cfg_yaml._dbg] [.dotfiles/config.yaml] templating dotfiles entries
[ERR] config error: 'NoneType' object is not iterable 

Any additional information that would help reproduce the bug.

deadc0de6 commented 1 year ago

@acourtneybrown thanks for reporting this and sorry for the bug. It should be fixed with above commit, I'm gonna release a new version on homebrew today.

deadc0de6 commented 1 year ago

The dotfiles: entry is still mandatory but it will now be transparently added if not present (without warning) so that the user experience is smoother.

deadc0de6 commented 1 year ago

Version 1.12.8 with the bug fix is on its way to homebrew: https://github.com/Homebrew/homebrew-core/pull/121232