blue-build / modules

BlueBuild standard modules used for building your Atomic Images
Apache License 2.0
22 stars 26 forks source link

bug(chezmoi): `chezmoi-update.timer` fails when dotfile is deleted or renamed #219

Closed fiftydinar closed 1 month ago

fiftydinar commented 1 month ago

Solution: Use chezmoi update with --force flag to solve this.

This is probably intended to not interfere with local-user changes to the file.

However, I think that using --force flag would be useful in certain cases, especially if user or the program should not touch the dotfile.

Maybe additional option would be good for this, although, I don't know how to handle the scenario where some image-maintainer might want --force for some files & normal update for other files in the same repo.

I'm pinging you @exponentactivity, since you made the chezmoi module to look into this, as this is the 1st time I use chezmoi.

fiftydinar commented 1 month ago

When some dotfile is deleted or renamed, chezmoi-update.timer fails the whole updating process, no matter if every other file is unchanged in naming.

When manually running chezmoi update, it will ask if affected file should be overwrited. If approved, it makes the new file if it was previously deleted, while it additionally keeps the renamed file if previously renamed.

Using chezmoi update --force solves the issue with chezmoi-update.timer in mentioned case.

xynydev commented 1 month ago

If there's an opposite flag, one that skips those files without prompting, would be nice to make that on option. I was planning on including something like duplicate-file-policy: skip | replace in homefiles eventually.

fiftydinar commented 1 month ago

If there's an opposite flag, one that skips those files without prompting, would be nice to make that on option. I was planning on including something like duplicate-file-policy: skip | replace in homefiles eventually.

--keep-going flag is good for this purpose.

There is also --no-tty flag, which fixes the error that systemd unit can't access tty & it now shows this clearer error:

maj 09 12:30:38 fedora chezmoi[6918]: .var/app/com.github.neithern.g4music has changed since chezmoi last wrote it (overwrite/all-overwrite/skip/quit)? chezmoi: .var/app/com.github.neithern.g4music: EOF

It shows that systemd unit failed when this happens, but files are still updated, so it should be good.

So updating the chezmoi-update.service with this should be good for duplicate-file-policy: skip:

chezmoi update --no-tty --keep-going

While duplicate-file-policy: replace should look like this:

chezmoi update --no-tty --force

exponentactivity commented 1 month ago

Thanks for tagging me. I was looking into it when i saw https://github.com/blue-build/modules/issues/219#issuecomment-2102414453 . I didn't know about --no-tty and --keep-going, thanks!

I'll implement duplicate-file-policy like you said. I'm thinking duplicate-file-policy: "skip" will be the default, since that is non-desctructive.

fiftydinar commented 1 month ago

I'm thinking duplicate-file-policy: "skip" will be the default, since that is non-desctructive.

I agree