Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve err reporting on failed config migration #4209

Closed
kas2020-commits opened this issue Jan 24, 2025 · 0 comments · Fixed by #4210
Closed

Improve err reporting on failed config migration #4209

kas2020-commits opened this issue Jan 24, 2025 · 0 comments · Fixed by #4210
Labels
enhancement New feature or request

Comments

@kas2020-commits
Copy link
Contributor

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.

@kas2020-commits kas2020-commits added the enhancement New feature or request label Jan 24, 2025
stefanhaller added a commit that referenced this issue Jan 30, 2025
- **PR Description**

closes #4209

- **Please check if the PR fulfills these requirements**

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [ ] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [ ] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [ ] If a new UserConfig entry was added, make sure it can be
hot-reloaded (see
[here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig))
* [ ] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant