From b5f9a49d911ce5ee1e8859968f449835d4147c5f Mon Sep 17 00:00:00 2001 From: Richard Li <98242479+RichhLi@users.noreply.github.com> Date: Thu, 29 Jun 2023 19:09:49 -0700 Subject: [PATCH] Fix PATH Order (#1679) * fix path order Signed-off-by: Richard Li * whitespace Signed-off-by: Richard Li --------- Signed-off-by: Richard Li Co-authored-by: Richard Li --- pkg/lang/ir/v1/system.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pkg/lang/ir/v1/system.go b/pkg/lang/ir/v1/system.go index d41592155..f6ec6a7e8 100644 --- a/pkg/lang/ir/v1/system.go +++ b/pkg/lang/ir/v1/system.go @@ -353,15 +353,20 @@ func (g *generalGraph) compileBaseImage() (llb.State, error) { // 1. configured paths in the Starlark frontend `runtime.environ(extra_path=[...])` // 2. paths in the base image // 3. others added during the image building (Python paths, etc.) - extraPaths := make(map[string]bool) - for _, path := range strings.Split(kv[1], ":") { - extraPaths[path] = true - } + + // iterate over the original paths and add them to the map + pathMap := make(map[string]bool) for _, path := range g.RuntimeEnvPaths { - extraPaths[path] = false + pathMap[path] = true } - for path, required := range extraPaths { - if required { + // split the PATH into different paths + newPaths := strings.Split(kv[1], ":") + // iterate over the new paths + for _, path := range newPaths { + // check if the path is already in the map + if _, ok := pathMap[path]; !ok { + // if not, add the path to the map and slice + pathMap[path] = true g.RuntimeEnvPaths = append(g.RuntimeEnvPaths, path) } }