Repository: jesseduffield/lazygit (language: go)

Issue:
Improve err reporting on failed config migration
**Is your feature request related to a problem? Please describe.**
I recently had my lazygit config become deprecated. Specifically from [this key path migration](https://github.com/jesseduffield/lazygit/blob/40d6800fd35ad2d5c6d96d6f08ffa42d4c764ad3/pkg/config/app_config.go#L228).

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:

```go
	// 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](https://github.com/jesseduffield/lazygit/blob/40d6800fd35ad2d5c6d96d6f08ffa42d4c764ad3/pkg/config/app_config.go#L249).



Discussion / hints:

Fix patch:
diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go
index 381bbe07671..5d240b87d04 100644
--- a/pkg/config/app_config.go
+++ b/pkg/config/app_config.go
@@ -245,9 +245,11 @@ func migrateUserConfig(path string, content []byte) ([]byte, error) {
 
 	// Write config back if changed
 	if string(changedContent) != string(content) {
+		fmt.Println("Provided user config is deprecated but auto-fixable. Attempting to write fixed version back to file...")
 		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 nil, fmt.Errorf("While attempting to write back fixed user config to %s, an error occurred: %s", path, err)
 		}
+		fmt.Printf("Success. New config written to %s\n", path)
 		return changedContent, nil
 	}
 


Test patch: