Skip to content

Commit

Permalink
Merge pull request #3548 from ActiveState/DX-3116
Browse files Browse the repository at this point in the history
Fix path ordering
  • Loading branch information
MDrakos authored Oct 18, 2024
2 parents c3b9e85 + 97813a8 commit 1c7e526
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/runners/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/ActiveState/cli/internal/output"
"github.com/ActiveState/cli/internal/primer"
"github.com/ActiveState/cli/internal/runbits/rationalize"
"github.com/ActiveState/cli/internal/runbits/runtime"
runtime_runbit "github.com/ActiveState/cli/internal/runbits/runtime"
"github.com/ActiveState/cli/internal/runbits/runtime/trigger"
"github.com/ActiveState/cli/internal/subshell"
"github.com/ActiveState/cli/internal/virtualenvironment"
Expand Down
28 changes: 27 additions & 1 deletion pkg/runtime/internal/envdef/collection.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package envdef

import (
"os"
"path/filepath"
"runtime"
"sync"

"github.com/ActiveState/cli/internal/errs"
Expand Down Expand Up @@ -63,5 +65,29 @@ func (c *Collection) Environment(installPath string, inherit bool) (map[string]s
}
}
constants := NewConstants(installPath)
return result.ExpandVariables(constants).GetEnv(inherit), nil
env := result.ExpandVariables(constants).GetEnv(inherit)
promotePath(env)
return env, nil
}

// promotPath is a temporary fix to ensure that the PATH is interpreted correctly on Windows
// Should be properly addressed by https://activestatef.atlassian.net/browse/DX-3030
func promotePath(env map[string]string) {
if runtime.GOOS != "windows" {
return
}

PATH, exists := env["PATH"]
if !exists {
return
}

// If Path exists, prepend PATH values to it
Path, pathExists := env["Path"]
if !pathExists {
return
}

env["Path"] = PATH + string(os.PathListSeparator) + Path
delete(env, "PATH")
}
4 changes: 1 addition & 3 deletions test/integration/exec_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import (
"runtime"
"strings"
"testing"
"time"

"github.com/ActiveState/cli/internal/constants"
"github.com/ActiveState/cli/internal/environment"
"github.com/ActiveState/cli/internal/fileutils"
"github.com/ActiveState/cli/internal/testhelpers/e2e"
"github.com/ActiveState/cli/internal/testhelpers/suite"
"github.com/ActiveState/cli/internal/testhelpers/tagsuite"
"github.com/ActiveState/termtest"
)

type ExecIntegrationTestSuite struct {
Expand Down Expand Up @@ -176,7 +174,7 @@ func (suite *ExecIntegrationTestSuite) TestExeBatArguments() {
inputs := []string{"a<b", "b>a", "hello world", "&whoami", "imnot|apipe", "%NotAppData%", "^NotEscaped", "(NotAGroup)"}
outputs := `"` + strings.Join(inputs, `" "`) + `"`
cp = ts.SpawnWithOpts(e2e.OptArgs(append([]string{"exec", reportBat, "--"}, inputs...)...))
cp.Expect(outputs, termtest.OptExpectTimeout(5*time.Second))
cp.Expect(outputs, e2e.RuntimeBuildSourcingTimeoutOpt)
cp.ExpectExitCode(0)
}

Expand Down

0 comments on commit 1c7e526

Please sign in to comment.