From c6d1de3397755835084f9893f0bdd31b76bab599 Mon Sep 17 00:00:00 2001 From: Will Wang Date: Wed, 24 Jul 2024 12:10:32 +0800 Subject: [PATCH] allow for dangling symlinks Signed-off-by: Will Wang --- cli/config/configfile/file.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cli/config/configfile/file.go b/cli/config/configfile/file.go index a94451e781..a031fb468d 100644 --- a/cli/config/configfile/file.go +++ b/cli/config/configfile/file.go @@ -4,6 +4,7 @@ import ( "encoding/base64" "encoding/json" "io" + "io/fs" "os" "path/filepath" "strings" @@ -167,9 +168,9 @@ func (configFile *ConfigFile) Save() (retErr error) { return errors.Wrap(err, "error closing temp file") } - // Handle situation where the configfile is a symlink cfgFile := configFile.Filename - if f, err := filepath.EvalSymlinks(cfgFile); err == nil { + // Handle situations where `configFile.Filename` is a symlink, and allow for dangling symlinks + if f, err := filepath.EvalSymlinks(cfgFile); err == nil || errors.Is(err, fs.ErrNotExist) { cfgFile = f }