Skip to content

Commit

Permalink
Merge pull request #7544 from mook-as/moby-client/bin-path
Browse files Browse the repository at this point in the history
Moby client: Always add bin dir to PATH
  • Loading branch information
jandubois authored Sep 25, 2024
2 parents 0efb3bd + bb5ce13 commit 733b6a4
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 733b6a4

Please sign in to comment.