Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions internal/locale/locales/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,10 @@ run_description:
other: Run your project scripts
scripts_description:
other: Show project scripts
runtime_setup_in_use_err:
runtime_setup_in_use_warning:
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:
[WARNING]Warning:[/RESET] the runtime for this project is in use, it is recommended you restart any active processes to avoid conflicts.
The following processes are currently using this runtime:
{{.V0}}
runtime_alternative_file_transforms_err:
other: "Could not apply necessary file transformations after unpacking."
Expand Down
21 changes: 0 additions & 21 deletions internal/runbits/runtime/rationalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strings"

"github.com/ActiveState/cli/internal/errs"
"github.com/ActiveState/cli/internal/graph"
"github.com/ActiveState/cli/internal/locale"
buildscript_runbit "github.com/ActiveState/cli/internal/runbits/buildscript"
"github.com/ActiveState/cli/internal/runbits/rationalize"
Expand All @@ -22,22 +21,13 @@ var ErrBuildscriptNotExist = buildscript_runbit.ErrBuildscriptNotExist

var ErrBuildScriptNeedsCommit = errors.New("buildscript is dirty, need to run state commit")

type RuntimeInUseError struct {
Processes []*graph.ProcessInfo
}

func (err RuntimeInUseError) Error() string {
return "runtime is in use"
}

func rationalizeUpdateError(prime primeable, rerr *error) {
if *rerr == nil {
return
}

var artifactCachedBuildErr *runtime.ArtifactCachedBuildFailed
var artifactBuildErr *runtime.ArtifactBuildError
var runtimeInUseErr *RuntimeInUseError

switch {
// Artifact cached build errors
Expand All @@ -60,17 +50,6 @@ func rationalizeUpdateError(prime primeable, rerr *error) {
errs.SetInput(),
)

// Runtime in use
case errors.As(*rerr, &runtimeInUseErr):
list := []string{}
for _, proc := range runtimeInUseErr.Processes {
list = append(list, fmt.Sprintf(" - %s (process: %d)", proc.Exe, proc.Pid))
}
*rerr = errs.WrapUserFacing(*rerr,
locale.Tr("runtime_setup_in_use_err", strings.Join(list, "\n")),
errs.SetInput(),
)

// Headless
case errors.Is(*rerr, rationalize.ErrHeadless):
*rerr = errs.WrapUserFacing(*rerr,
Expand Down
8 changes: 7 additions & 1 deletion internal/runbits/runtime/runtime.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package runtime_runbit

import (
"fmt"
"net/url"
"os"
"strings"

anaConsts "github.com/ActiveState/cli/internal/analytics/constants"
"github.com/ActiveState/cli/internal/analytics/dimensions"
Expand Down Expand Up @@ -236,7 +238,11 @@ func Update(
defer cancel()
if procs, err := prime.SvcModel().GetProcessesInUse(ctx, rt.Env(false).ExecutorsPath); err == nil {
if len(procs) > 0 {
return nil, &RuntimeInUseError{procs}
list := []string{}
for _, proc := range procs {
list = append(list, fmt.Sprintf(" - %s (process: %d)", proc.Exe, proc.Pid))
}
prime.Output().Notice(locale.Tr("runtime_setup_in_use_warning", strings.Join(list, "\n")))
}
} else {
multilog.Error("Unable to determine if runtime is in use: %v", errs.JoinMessage(err))
Expand Down
9 changes: 6 additions & 3 deletions test/integration/runtime_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ func (suite *RuntimeIntegrationTestSuite) TestInterruptSetup() {
}

func (suite *RuntimeIntegrationTestSuite) TestInUse() {
if runtime.GOOS == "windows" {
// https://activestatef.atlassian.net/browse/DX-2926
suite.T().Skip("interrupting on windows is currently broken when ran via CI")
}
if runtime.GOOS == "darwin" {
return // gopsutil errors on later versions of macOS (DX-2723)
}
Expand All @@ -128,10 +132,9 @@ func (suite *RuntimeIntegrationTestSuite) TestInUse() {
time.Sleep(1 * time.Second) // allow time for perl to start up

cp2 := ts.Spawn("install", "DateTime")
cp2.Expect("currently in use", e2e.RuntimeSourcingTimeoutOpt)
cp2.Expect("the runtime for this project is in use", e2e.RuntimeSourcingTimeoutOpt)
cp2.Expect("perl")
cp2.ExpectNotExitCode(0)
ts.IgnoreLogErrors()
cp2.ExpectExitCode(0)

cp.SendCtrlC()
cp.SendLine("exit")
Expand Down
Loading