Skip to content

Commit 78c6480

Browse files
author
Massimiliano Pippi
authored
make config init work on fresh installs (#531)
1 parent 9061584 commit 78c6480

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cli/config/init.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ var initFlags struct {
4949
func runInitCommand(cmd *cobra.Command, args []string) {
5050
logrus.Info("Executing `arduino config init`")
5151

52-
configFile := filepath.Join(viper.GetString("directories.Data"), "arduino-cli.yaml")
52+
dataDir := viper.GetString("directories.Data")
53+
if err := os.MkdirAll(dataDir, os.FileMode(0755)); err != nil {
54+
feedback.Errorf("Cannot create data directory: %v", err)
55+
os.Exit(errorcodes.ErrGeneric)
56+
}
57+
58+
configFile := filepath.Join(dataDir, "arduino-cli.yaml")
5359
err := viper.WriteConfigAs(configFile)
5460
if err != nil {
5561
feedback.Errorf("Cannot create config file: %v", err)

0 commit comments

Comments
 (0)