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

fix: allow finch commands to run using default config #1109

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cmd/finch/main_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
package main

import (
"errors"
"fmt"
"io"
"os"

"github.com/spf13/afero"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -41,7 +43,11 @@ func xmain(logger flog.Logger,
ecc,
)
if err != nil {
return fmt.Errorf("failed to load config: %w", err)
if errors.Is(err, os.ErrPermission) {
logger.Warnf("Failed to load config, using default values. You may need to be root or use sudo. (%s)", err)
} else {
return fmt.Errorf("failed to load config: %w", err)
}
}

return newApp(
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func Load(
return nil, fmt.Errorf("failed to ensure %q directory: %w", cfgPath, err)
}
if err := writeConfig(defCfg, fs, cfgPath); err != nil {
return nil, err
log.Warnf("Could not save default values to %q: %w", cfgPath, err)
}
return defCfg, nil
}
Expand Down
Loading