From e23458d2dd48cedab3a06d8fe3a483336624b693 Mon Sep 17 00:00:00 2001 From: Young Joon Lee Date: Tue, 10 Nov 2026 09:35:01 +0900 Subject: [PATCH] fix(config): name the next step in config init write errors Review follow-up to #127: the stat, write and rename failures in writePrivateConfig named the cause but not what to do next. --- internal/cli/configcmd.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/cli/configcmd.go b/internal/cli/configcmd.go index dd5a2a2..cbb83bd 100644 --- a/internal/cli/configcmd.go +++ b/internal/cli/configcmd.go @@ -200,7 +200,7 @@ func writePrivateConfig(file string, data []byte, overwrite bool) error { return fmt.Errorf("%s is owned by uid %d, not the user running this command; remove it or choose another --file", file, st.Uid) } } else if !os.IsNotExist(err) { - return fmt.Errorf("checking %s: %w", file, err) + return fmt.Errorf("checking %s: %w; check that its directory exists and you can read it, or choose another --file", file, err) } tmp, err := os.CreateTemp(filepath.Dir(file), ".rootfiles-config.*.tmp") if err != nil { @@ -210,7 +210,7 @@ func writePrivateConfig(file string, data []byte, overwrite bool) error { fail := func(step string, err error) error { _ = tmp.Close() _ = os.Remove(tmpPath) - return fmt.Errorf("%s for %s: %w; the previous file, if any, is unchanged", step, file, err) + return fmt.Errorf("%s for %s: %w; the previous file, if any, is unchanged; check free space and write permission in %s, then rerun", step, file, err, filepath.Dir(file)) } if err := tmp.Chmod(0600); err != nil { return fail("setting mode 0600", err) @@ -226,7 +226,7 @@ func writePrivateConfig(file string, data []byte, overwrite bool) error { } if err := os.Rename(tmpPath, file); err != nil { _ = os.Remove(tmpPath) - return fmt.Errorf("replacing %s: %w; the previous file, if any, is unchanged", file, err) + return fmt.Errorf("replacing %s: %w; the previous file, if any, is unchanged; check write permission in %s, then rerun or choose another --file", file, err, filepath.Dir(file)) } return nil }