Skip to content

Commit 78678a4

Browse files
committed
Merge branch version/0-37-0-RC1 to adopt changes from PR #2401
2 parents 889279e + 795573b commit 78678a4

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

internal/runners/clean/run_win.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"path/filepath"
1212

1313
"github.com/ActiveState/cli/internal/assets"
14+
"github.com/ActiveState/cli/internal/condition"
1415
"github.com/ActiveState/cli/internal/config"
1516
"github.com/ActiveState/cli/internal/errs"
1617
"github.com/ActiveState/cli/internal/exeutils"
@@ -106,14 +107,18 @@ func removeInstall(logFile string, params *UninstallParams, cfg *config.Instance
106107
return locale.WrapError(err, "err_state_exec")
107108
}
108109

109-
paths := []string{}
110+
// Schedule removal of the entire branch name directory.
111+
// This is because Windows often thinks the installation.InstallDirMarker and
112+
// constants.StateInstallerCmd files are still in use.
113+
branchDir := filepath.Dir(filepath.Dir(stateExec))
114+
if condition.InTest() && !params.All {
115+
// On CI, the installation root also contains cache and config directories, and they should
116+
// not be removed. Instead, just remove the installation bin directory.
117+
branchDir = filepath.Dir(stateExec)
118+
}
119+
paths := []string{branchDir}
110120
if params.All {
111-
// Schedule removal of the branch name directory and the config directory
112-
paths = append(paths, filepath.Dir(filepath.Dir(stateExec)))
113-
paths = append(paths, cfg.ConfigPath())
114-
} else {
115-
// Schedule the removal of just the bin directory.
116-
paths = append(paths, filepath.Dir(stateExec))
121+
paths = append(paths, cfg.ConfigPath()) // also remove the config directory
117122
}
118123
// If the transitional state tool path is known, we remove it. This is done in the background, because the transitional State Tool can be the initiator of the uninstall request
119124
if transitionalStateTool := cfg.GetString(installation.CfgTransitionalStateToolPath); transitionalStateTool != "" {

0 commit comments

Comments
 (0)