Skip to content

Improve err reporting on failed config migration #4209

@kas2020-commits

Description

@kas2020-commits

Is your feature request related to a problem? Please describe.
I recently had my lazygit config become deprecated. Specifically from this key path migration.

However my config file is a symlink to my /nix/store (it's managed by nix itself) so it's immutable. When I tried to open lazygit after this schema change, I only got this output to my shell:

2025/01/24 10:31:27 Couldn't write migrated config back to `/home/$USER/.config/lazygit/config.yml`: open /home/$USER/.config/lazygit/config.yml: read-only file system

which is not intuitive at all. I had to read the source code to finally find this snippet to explain why this happened:

	// Write config back if changed
	if string(changedContent) != string(content) {
		if err := os.WriteFile(path, changedContent, 0o644); err != nil {
			return nil, fmt.Errorf("Couldn't write migrated config back to `%s`: %s", path, err)
		}
		return changedContent, nil
	}

Describe the solution you'd like
I think lazygit should be telling the user that it's trying to rewrite my config file to self-heal it, especially if the os write leads to a failure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions