Skip to content

Fixed wrong IDE bundle-detection result caching #606

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

Merged
merged 1 commit into from
Apr 16, 2020
Merged
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
15 changes: 9 additions & 6 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ func IsBundledInDesktopIDE() bool {
executable, err := os.Executable()
if err != nil {
feedback.Errorf("Cannot get executable path: %v", err)
return viper.GetBool("IDE.Bundled")
return false
}

executablePath, err := filepath.EvalSymlinks(executable)
if err != nil {
feedback.Errorf("Cannot get executable path: %v", err)
return viper.GetBool("IDE.Bundled")
return false
}

ideDir := filepath.Dir(executablePath)
Expand All @@ -163,17 +163,20 @@ func IsBundledInDesktopIDE() bool {
for _, test := range tests {
if _, err := os.Stat(filepath.Join(ideDir, test)); err != nil {
// the test folder doesn't exist or is not accessible
return viper.GetBool("IDE.Bundled")
return false
}
}

// the CLI is bundled in the Arduino IDE

// Persist IDE-related config settings
viper.Set("IDE.Bundled", true)
viper.Set("IDE.Directory", ideDir)

// Check whether this is a portable install
if _, err := os.Stat(filepath.Join(ideDir, "portable")); err != nil {
viper.Set("IDE.Portable", true)
}

// Persist IDE-related config settings and return true
viper.Set("IDE.Bundled", false)
viper.Set("IDE.Directory", ideDir)
return true
}