Skip to content

Commit b506e81

Browse files
CLOUDP-312574: [Atlas CLI] Handle missing Compass installation more gracefully (#3958)
1 parent 1d62450 commit b506e81

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

internal/compass/compass.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,28 @@ package compass
1616

1717
import (
1818
"errors"
19+
"os"
1920
)
2021

2122
var (
2223
ErrCompassNotInstalled = errors.New("did not find MongoDB Compass, install: https://dochub.mongodb.org/core/install-compass")
2324
)
2425

2526
func Detect() bool {
26-
return binPath() != ""
27+
// Get the binary path
28+
bin := binPath()
29+
30+
// Check if the path is not empty
31+
if bin == "" {
32+
return false
33+
}
34+
35+
// Check if the directory exists
36+
if _, err := os.Stat(bin); os.IsNotExist(err) {
37+
return false
38+
}
39+
40+
return true
2741
}
2842

2943
func Run(username, password, mongoURI string) error {

0 commit comments

Comments
 (0)