From 6323d8efd55d9f5e15ff2d5ed6e99eeb4a449f6f Mon Sep 17 00:00:00 2001 From: Timofey Kirillov Date: Fri, 24 Mar 2023 14:23:16 +0300 Subject: [PATCH] fix: 'exec: werf-in-a-user-namespace: executable file not found in $PATH' when using buildah Signed-off-by: Timofey Kirillov --- pkg/host_cleaning/host_cleanup.go | 7 ++++++- pkg/werf/main.go | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/host_cleaning/host_cleanup.go b/pkg/host_cleaning/host_cleanup.go index 0cc85d5c62..cd05a0d285 100644 --- a/pkg/host_cleaning/host_cleanup.go +++ b/pkg/host_cleaning/host_cleanup.go @@ -86,7 +86,12 @@ func RunAutoHostCleanup(ctx context.Context, options AutoHostCleanupOptions) err args = append(args, "--docker-server-storage-path", *options.DockerServerStoragePath) } - cmd := exec.Command(os.Args[0], args...) + executableName := os.Getenv("WERF_ORIGINAL_EXECUTABLE") + if executableName == "" { + executableName = os.Args[0] + } + + cmd := exec.Command(executableName, args...) var env []string for _, spec := range os.Environ() { diff --git a/pkg/werf/main.go b/pkg/werf/main.go index de83b00637..e92fca95dc 100644 --- a/pkg/werf/main.go +++ b/pkg/werf/main.go @@ -164,5 +164,11 @@ func Init(tmpDirOption, homeDirOption string) error { return fmt.Errorf("error setting werf last run at timestamp: %w", err) } + if os.Getenv("WERF_ORIGINAL_EXECUTABLE") == "" { + if err := os.Setenv("WERF_ORIGINAL_EXECUTABLE", os.Args[0]); err != nil { + return fmt.Errorf("error setting werf original args env var: %w", err) + } + } + return nil }