Skip to content

Commit

Permalink
Moby client: Always add bin dir to PATH
Browse files Browse the repository at this point in the history
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 <mark.yen@suse.com>
  • Loading branch information
mook-as committed Sep 25, 2024
1 parent 0efb3bd commit bb5ce13
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/rancher-desktop/backend/containerClient/mobyClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) }`,
},
});

Expand Down

0 comments on commit bb5ce13

Please sign in to comment.