From 89b0b79b471b970139ffc2b5c9f5919b1e38c77a Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Mon, 24 Mar 2014 16:30:42 +1000 Subject: [PATCH 1/2] in Windows cmd.exe, testing for a file in a non-existant dir fails hard, so I rewrote the cfg dir code to keep trying until it finds an existant dir --- config.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index a81ee26..34adb9c 100644 --- a/config.go +++ b/config.go @@ -51,7 +51,10 @@ func getCfgDir(name string) (string, error) { // *nix if home := os.Getenv("HOME"); home != "" { - return filepath.Join(home, name), nil + dir := filepath.Join(home, name) + if _, err := os.Stat(dir); err == nil { + return dir, nil + } } // Windows @@ -61,7 +64,10 @@ func getCfgDir(name string) (string, error) { "USERPROFILE", } { if val := os.Getenv(env); val != "" { - return filepath.Join(val, "boot2docker"), nil + dir := filepath.Join(val, "boot2docker") + if _, err := os.Stat(dir); err == nil { + return dir, nil + } } } // Fallback to current working directory as a last resort From cfb5cd1b39530e9c0bdde8a09ce1568551035adf Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Mon, 24 Mar 2014 20:38:03 +1000 Subject: [PATCH 2/2] if we're doing last resourt, use a directory that exists, not a .boot2docker subdir of it. --- config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.go b/config.go index 34adb9c..cc698fc 100644 --- a/config.go +++ b/config.go @@ -75,7 +75,7 @@ func getCfgDir(name string) (string, error) { if err != nil { return "", err } - return filepath.Join(cwd, name), nil + return cwd, nil } // Read configuration from both profile and flags. Flags override profile.