From 117ddcee887b657c188bfeaf76d7895481a26fc1 Mon Sep 17 00:00:00 2001 From: Chris Bainbridge Date: Fri, 25 Jun 2021 22:53:31 +0100 Subject: [PATCH] Fix fleetctl preview error: docker-compose "Cannot open self" (#1210) The following error occurs when running `fleetctl preview`: Starting simulated hosts... [13247] Cannot open self /home/chrb/.fleet/preview/osquery/docker-compose or archive /home/chrb/.fleet/preview/osquery/docker-compose.pkg Failed to run docker-compose This is caused by a missing PATH environment variable when launching docker-compose (which appears to re-exec the docker-compose binary). Fix this by passing on the current environment. --- cmd/fleetctl/preview.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/fleetctl/preview.go b/cmd/fleetctl/preview.go index 4877dd9a6d..c6f056e124 100644 --- a/cmd/fleetctl/preview.go +++ b/cmd/fleetctl/preview.go @@ -174,7 +174,7 @@ Use the stop and reset subcommands to manage the server and dependencies once st fmt.Println("Starting simulated hosts...") cmd := exec.Command("docker-compose", "up", "-d", "--remove-orphans") cmd.Dir = filepath.Join(previewDir, "osquery") - cmd.Env = append(cmd.Env, + cmd.Env = append(os.Environ(), "ENROLL_SECRET="+secrets.Secrets[0].Secret, "FLEET_URL="+address, ) @@ -355,7 +355,7 @@ func previewStopCommand() *cli.Command { cmd := exec.Command("docker-compose", "stop") cmd.Dir = filepath.Join(previewDir, "osquery") - cmd.Env = append(cmd.Env, + cmd.Env = append(os.Environ(), // Note that these must be set even though they are unused while // stopping because docker-compose will error otherwise. "ENROLL_SECRET=empty", @@ -404,7 +404,7 @@ func previewResetCommand() *cli.Command { cmd := exec.Command("docker-compose", "rm", "-sf") cmd.Dir = filepath.Join(previewDir, "osquery") - cmd.Env = append(cmd.Env, + cmd.Env = append(os.Environ(), // Note that these must be set even though they are unused while // stopping because docker-compose will error otherwise. "ENROLL_SECRET=empty",