Skip to content

Commit 3a81d97

Browse files
committed
Fixes #121 - Fix up cmd environment
exec.Cmd defaults to the current process's environment which is what we almost always want. But in cases when we need to set a command `Env` we can't just append to its own `Env`. We need to explicitly use `os.Environ()` and append to that.
1 parent b985032 commit 3a81d97

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cmd/up.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"flag"
55
"strings"
6+
"os"
67

78
"github.com/mitchellh/cli"
89
"github.com/posener/complete"
@@ -58,8 +59,14 @@ func (c *UpCommand) Run(args []string) int {
5859

5960
vagrantUp := execCommandWithOutput("vagrant", vagrantArgs, c.UI)
6061

62+
env := os.Environ()
63+
// To allow mockExecCommand injects its environment variables.
64+
if vagrantUp.Env != nil {
65+
env = vagrantUp.Env
66+
}
67+
6168
if !c.withGalaxy {
62-
vagrantUp.Env = append(vagrantUp.Env, "SKIP_GALAXY=true")
69+
vagrantUp.Env = append(env, "SKIP_GALAXY=true")
6370
}
6471

6572
err := vagrantUp.Run()

0 commit comments

Comments
 (0)