Skip to content

Commit 5c48c84

Browse files
committed
Correctly handle error when looking for configuration on parent folders
1 parent 3d25175 commit 5c48c84

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

commands/root/root.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"fmt"
2222
"io/ioutil"
2323
"os"
24-
"path/filepath"
2524

2625
"github.com/arduino/arduino-cli/output"
2726

@@ -136,12 +135,6 @@ func initConfigs() {
136135
commands.Config = conf
137136
}
138137

139-
// Navigate through folders
140-
pwd, err := filepath.Abs(".")
141-
if err != nil {
142-
logrus.WithError(err).Warn("Did not manage to find current path")
143-
}
144-
145138
// Read configuration from global config file
146139
if commands.Config.ConfigFile.Exist() {
147140
logrus.Infof("Reading configuration from %s", commands.Config.ConfigFile)
@@ -161,7 +154,11 @@ func initConfigs() {
161154
}
162155

163156
// Read configuration from parent folders (project config)
164-
commands.Config.Navigate("/", pwd)
157+
if pwd, err := paths.Getwd(); err != nil {
158+
logrus.WithError(err).Warn("Did not manage to find current path")
159+
} else {
160+
commands.Config.Navigate("/", pwd.String())
161+
}
165162

166163
// Read configuration from environment vars
167164
commands.Config.LoadFromEnv()

0 commit comments

Comments
 (0)