Skip to content
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

Merge "PATH" with Window's "Path". #3479

Merged
merged 1 commit into from
Sep 5, 2024
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
13 changes: 9 additions & 4 deletions internal/runners/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"

Expand All @@ -31,7 +32,7 @@ import (
"github.com/ActiveState/cli/pkg/platform/model"
"github.com/ActiveState/cli/pkg/project"
"github.com/ActiveState/cli/pkg/projectfile"
"github.com/ActiveState/cli/pkg/runtime"
rt "github.com/ActiveState/cli/pkg/runtime"
)

type Configurable interface {
Expand Down Expand Up @@ -98,7 +99,7 @@ func (s *Exec) Run(params *Params, args ...string) (rerr error) {
// If the path passed resolves to a runtime dir (ie. has a runtime marker) then the project is not used
var proj *project.Project
var err error
if params.Path != "" && runtime.IsRuntimeDir(params.Path) {
if params.Path != "" && rt.IsRuntimeDir(params.Path) {
projectDir = projectFromRuntimeDir(s.cfg, params.Path)
proj, err = project.FromPath(projectDir)
if err != nil {
Expand Down Expand Up @@ -145,14 +146,18 @@ func (s *Exec) Run(params *Params, args ...string) (rerr error) {

if !fileutils.TargetExists(exeTarget) {
// Report recursive execution of executor: The path for the executable should be different from the default bin dir
exesOnPath := osutils.FilterExesOnPATH(exeTarget, env["PATH"], func(exe string) bool {
filter := func(exe string) bool {
v, err := executors.IsExecutor(exe)
if err != nil {
logging.Error("Could not find out if executable is an executor: %s", errs.JoinMessage(err))
return true // This usually means there's a permission issue, which means we likely don't own it
}
return !v
})
}
exesOnPath := osutils.FilterExesOnPATH(exeTarget, env["PATH"], filter)
if runtime.GOOS == "windows" {
exesOnPath = append(exesOnPath, osutils.FilterExesOnPATH(exeTarget, env["Path"], filter)...)
}

if len(exesOnPath) > 0 {
exeTarget = exesOnPath[0]
Expand Down
Loading