Skip to content

Commit

Permalink
Revert "Merge pull request #2885 from ActiveState/mitchell/dx-2091"
Browse files Browse the repository at this point in the history
This reverts commit 880d41b, reversing
changes made to 7aba119.
  • Loading branch information
mitchell-as committed Feb 6, 2024
1 parent a4235d2 commit f30429c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 53 deletions.
5 changes: 0 additions & 5 deletions internal/locale/locales/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
33 changes: 0 additions & 33 deletions internal/osutils/osutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
15 changes: 0 additions & 15 deletions pkg/platform/runtime/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f30429c

Please sign in to comment.