anishathalye / dotbot

A tool that bootstraps your dotfiles ⚡️
MIT License
6.93k stars 286 forks source link

install abends if config yaml uses 2 spaces for indentation #364

Closed tessus closed 1 day ago

tessus commented 2 weeks ago

I've just found out that I get the following errors, if the install.conf.yaml uses 2 spaces for indentation rather than 4.

All targets have been cleaned
An error was encountered while executing action link
'NoneType' object has no attribute 'get'
Action link not handled
An error was encountered while executing action create
'NoneType' object has no attribute 'get'
Action create not handled
An error was encountered while executing action link
'NoneType' object has no attribute 'get'
Action link not handled

I thought the config yaml file has to be a valid yaml file, but apparently this is not the case.

It specifically requires an indentation with 4 spaces. @anishathalye can you please shed some light on this? According to every yaml validator my config file is valid, but install abends with the above messages. All is well again, when I change to 4 spaces.

anishathalye commented 2 weeks ago

Could you share (a potentially redacted) version of your YAML file here, or if you're not comfortable sharing publicly, email it to me?

kurtmckee commented 1 week ago

@tessus My guess is that your file looks like this:

- link:
  ~/.bashrc: bash/bashrc.sh

This is valid YAML because YAML defaults to null when a key has no value:

[
  {
    "link": None,
    "~/.bashrc": "bash/bashrc.sh"
  }
]

However, this is not well-formed because it doesn't parse to dotbot's required format.

If your file looks like the above, please close this issue because it's not a dotbot problem.


For reference, this is correct syntax using 2-space indentation:

- link:
    ~/.bashrc: bash/bashrc.sh

and this is the correct syntax using 4-space indentation:

-   link:
        ~/.bashrc: bash/bashrc.sh

which parses to:

[
  {
    "link": {"~/.bashrc": "bash/bashrc.sh"}
  }
]
tessus commented 1 day ago

Yes, my file looks like that. Why? Because 2 spaces are used for indentation. ;-)

But thank you. Your explanation makes sense. Now I only have to figure out how I explain this to every editor that uses .editorconfig with

[*.yaml]
indent_style = space
indent_size = 2
kurtmckee commented 1 day ago

Super! Please close this issue.

tessus commented 1 day ago

I still think this is a dotbot issue. Ansible parses files with 2 spaces just fine.