From bb5ce13d762dbcfd46804bbb4e25ce545059b7b5 Mon Sep 17 00:00:00 2001 From: Mark Yen Date: Wed, 25 Sep 2024 10:09:48 -0700 Subject: [PATCH] Moby client: Always add bin dir to PATH When running any of the tools, always add the `bin` directory to the `PATH` so that it would be available even for docker CLI plugins (e.g. `docker-compose`). Fixes #7543 Signed-off-by: Mark Yen --- .../backend/containerClient/mobyClient.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/rancher-desktop/backend/containerClient/mobyClient.ts b/pkg/rancher-desktop/backend/containerClient/mobyClient.ts index 713bd0e6248..8fba6a965cc 100644 --- a/pkg/rancher-desktop/backend/containerClient/mobyClient.ts +++ b/pkg/rancher-desktop/backend/containerClient/mobyClient.ts @@ -470,15 +470,23 @@ export class MobyClient implements ContainerEngineClient { runClient(args: string[], stdio: 'pipe', options?: runClientOptions): Promise<{ stdout: string; stderr: string; }>; runClient(args: string[], stdio: 'stream', options?: runClientOptions): ReadableProcess; runClient(args: string[], stdio?: 'ignore' | 'pipe' | 'stream' | Log, options?: runClientOptions) { + // Always add the `bin` directory, as docker CLI plugins may need them too. + const dirsToAdd = [path.join(paths.resources, process.platform, 'bin')]; const executableName = options?.executable ?? this.executable; const isCLIPlugin = /^docker-(?!credential-)/.test(executableName); + const binType = isCLIPlugin ? 'docker-cli-plugins' : 'bin'; - const binDir = path.join(paths.resources, process.platform, binType); - const executable = path.resolve(binDir, executableName); + const executableDir = path.join(paths.resources, process.platform, binType); + const executable = path.resolve(executableDir, executableName); + + if (isCLIPlugin) { + dirsToAdd.push(executableDir); + } + const opts = _.merge({}, options ?? {}, { env: { DOCKER_HOST: this.endpoint, - PATH: `${ process.env.PATH }${ path.delimiter }${ binDir }`, + PATH: `${ process.env.PATH }${ path.delimiter }${ dirsToAdd.join(path.delimiter) }`, }, });