anishathalye / anishathalye/dotbot

Clean directive does not clean everything

Open
#392 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
8k
Forks
320
PR merge metrics
No merged PRs in 30d

Description

First of all, I read https://github.com/anishathalye/dotbot/wiki/Tips-and-Tricks#how-can-i-have-different-groups-of-tasks-for-different-hosts-with-different-configurations but there's one problem not mentioned anywhere:

What happens when we change the profile / config on a machine and we have symlinks left over (not included in the current link directives)?

I would expect that `clean: ["~"]` would take care of that, but it doesn't! Clean only cleans dead symlinks! But if we install a different profile, there's nothing dead as all our source files are there in our dotfiles repository.

This is actually not a source code bug, because the code works exactly like the documentation. Yes, using `force: true` does not really change anything because the doc says _"force | Remove dead links even if they don't point to a file inside the dotfiles
directory (default: false)"_ so actually I'm arguing that the intent here is wrong.

We actually want to clean ALL leftover symlinks that are no longer explicitly linked. Is there any realistic scenario in which we would like to keep them, that is not already satisfied by using the built-in filter for clean?

Moving forward, to make dotbot actually behave properly for my multiple machine/os setup, I made this modification in the clean logic: https://github.com/dorinclisu/dotbot/commit/0c6517323ce43cc6d2557eca78a7e767d254b853

What do you think? I can submit a PR with one of these variants:
- Modify the behavior exactly like in my fork commit.
- Add another config key such as "managed" and perform the clean when true, default=false. The advantage of this would be full backwards compatibility and allow opt-in, but it may unnecessarily increase complexity if nobody is abusing the current behavior.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.