From 1c6a8ecf2e83cb676bdae3e7edb1006d3c6db31e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 25 Apr 2024 19:25:13 +0200 Subject: [PATCH] cli-plugins: PluginRunCommand: use cmd.Environ instead of os.Environ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 50117590567998307eba377295a1ec24e214ccc7 implemented a fix that caused the current environment to be discarded, using `os.Environ()`. On Windows, `os.Environ()` may produce an incorrect value for `PWD`, for which a new function was added in go1.19; - https://tip.golang.org/doc/go1.19#osexecpkgosexec - https://go-review.googlesource.com/c/go/+/401340 Replace the use of `os.Environ()` with `cmd.Environ()` to address that. Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 5ccb48459b3e4307432f0c3c4e5862d68e00cff3) Signed-off-by: Paweł Gronowski --- cli-plugins/manager/manager.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cli-plugins/manager/manager.go b/cli-plugins/manager/manager.go index d3b7b7b52601..031b04f6bb49 100644 --- a/cli-plugins/manager/manager.go +++ b/cli-plugins/manager/manager.go @@ -240,8 +240,7 @@ func PluginRunCommand(dockerCli command.Cli, name string, rootcmd *cobra.Command cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - cmd.Env = os.Environ() - cmd.Env = append(cmd.Env, ReexecEnvvar+"="+os.Args[0]) + cmd.Env = append(cmd.Environ(), ReexecEnvvar+"="+os.Args[0]) cmd.Env = appendPluginResourceAttributesEnvvar(cmd.Env, rootcmd, plugin) return cmd, nil