From f30429c8e9f2f9c75f9cf3a66a5adbc0071e9dd0 Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 6 Feb 2024 13:31:01 -0500 Subject: [PATCH] Revert "Merge pull request #2885 from ActiveState/mitchell/dx-2091" This reverts commit 880d41bc00698de48ee9179b210193478ae316b0, reversing changes made to 7aba119bb4d39ca137a7c6ed3aae6748f7b51d24. --- internal/locale/locales/en-us.yaml | 5 ----- internal/osutils/osutils.go | 33 ----------------------------- pkg/platform/runtime/setup/setup.go | 15 ------------- 3 files changed, 53 deletions(-) diff --git a/internal/locale/locales/en-us.yaml b/internal/locale/locales/en-us.yaml index 49cf3904eb..ecc5759e69 100644 --- a/internal/locale/locales/en-us.yaml +++ b/internal/locale/locales/en-us.yaml @@ -189,11 +189,6 @@ run_description: other: Run your project scripts scripts_description: other: Show project scripts -runtime_setup_in_use_err: - other: | - Could not update your runtime as it is currently in use. Please stop any active runtime processes and try again. State Tool found the following processes to be using the runtime: - - {{.V0}} runtime_alternative_file_transforms_err: other: "Could not apply necessary file transformations after unpacking." scripts_no_scripts: diff --git a/internal/osutils/osutils.go b/internal/osutils/osutils.go index 5c3e65782a..3618d31389 100644 --- a/internal/osutils/osutils.go +++ b/internal/osutils/osutils.go @@ -6,11 +6,8 @@ import ( "os/exec" "path" "path/filepath" - "runtime" "strings" - "github.com/shirou/gopsutil/v3/process" - "github.com/ActiveState/cli/internal/errs" "github.com/ActiveState/cli/internal/fileutils" "github.com/ActiveState/cli/internal/multilog" @@ -126,33 +123,3 @@ func ExecutableName() string { name = strings.TrimSuffix(name, path.Ext(name)) return name } - -// GetProcessesInUse returns a map of currently running executables to their process IDs where -// those executables are in the given directory or a subdirectory of that given directory. -func GetProcessesInUse(dir string) map[string]int32 { - inUse := map[string]int32{} - - procs, err := process.Processes() - if err != nil { - multilog.Error("Unable to get running processes: %v", err) - return inUse - } - - if runtime.GOOS != "linux" { - dir = strings.ToLower(dir) // Windows and macOS filesystems are case-insensitive - } - for _, p := range procs { - exe, err := p.Exe() - if err != nil { - continue // probably a permission error; ignore - } - exeToCompare := exe - if runtime.GOOS != "linux" { - exeToCompare = strings.ToLower(exeToCompare) // Windows and macOS filesystems are case-insensitive - } - if strings.Contains(exeToCompare, dir) { - inUse[exe] = p.Pid - } - } - return inUse -} diff --git a/pkg/platform/runtime/setup/setup.go b/pkg/platform/runtime/setup/setup.go index 5268d3192e..c380f23764 100644 --- a/pkg/platform/runtime/setup/setup.go +++ b/pkg/platform/runtime/setup/setup.go @@ -23,7 +23,6 @@ import ( "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/internal/logging" "github.com/ActiveState/cli/internal/multilog" - "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/proxyreader" "github.com/ActiveState/cli/internal/rollbar" @@ -113,11 +112,6 @@ type ProgressReportError struct { *errs.WrapperError } -type RuntimeInUseError struct { - *locale.LocalizedError - Processes map[string]int32 // exe path to process ID -} - type Targeter interface { CommitUUID() strfmt.UUID Name() string @@ -212,15 +206,6 @@ func (s *Setup) Update() (rerr error) { return locale.NewInputError("err_runtime_setup_root", "Cannot set up a runtime in the root directory. Please specify or run from a user-writable directory.") } - procs := osutils.GetProcessesInUse(ExecDir(s.target.Dir())) - if len(procs) > 0 { - list := []string{} - for exe, pid := range procs { - list = append(list, fmt.Sprintf(" - %s (process: %d)", exe, pid)) - } - return &RuntimeInUseError{locale.NewInputError("runtime_setup_in_use_err", "", strings.Join(list, "\n")), procs} - } - // Update all the runtime artifacts artifacts, err := s.updateArtifacts() if err != nil {