diff --git a/core/src/mutagen.ts b/core/src/mutagen.ts index a12d8a0caa..b11d07453b 100644 --- a/core/src/mutagen.ts +++ b/core/src/mutagen.ts @@ -213,14 +213,10 @@ class _MutagenMonitor extends TypedEventEmitter { const mutagenOpts = [mutagenPath, "sync", "monitor", "--template", "{{ json . }}", "--long"] log.silly(() => `Spawning mutagen using respawn: "${mutagenOpts.join(" ")}"`) - const sshPath = await getMutagenSshPath(log) - if (sshPath) { - log.debug(`Mutagen will be used with the faux SSH transport located in ${sshPath}`) - } const proc = respawn(mutagenOpts, { cwd: dataDir, name: "mutagen", - env: getMutagenEnv({ dataDir, logLevel: "debug", sshPath }), + env: getMutagenEnv({ dataDir, logLevel: "debug" }, log), maxRestarts, sleep: 3000, kill: 500, @@ -708,7 +704,7 @@ export class Mutagen { cwd: this.dataDir, args, log: this.log, - env: getMutagenEnv({ dataDir: this.dataDir }), + env: await getMutagenEnv({ dataDir: this.dataDir }, this.log), }) } catch (err) { if (!(err instanceof ChildProcessError)) { @@ -892,24 +888,24 @@ export function getMutagenDataDir({ ctx, log }: MutagenDaemonParams) { */ type MutagenEnv = { MUTAGEN_DATA_DIRECTORY: string - MUTAGEN_LOG_LEVEL?: string MUTAGEN_SSH_PATH?: string + MUTAGEN_LOG_LEVEL?: string } type MutagenEnvValues = { dataDir: string logLevel?: string - sshPath?: string } -export function getMutagenEnv({ dataDir, logLevel, sshPath }: MutagenEnvValues): MutagenEnv { - const env: MutagenEnv = { MUTAGEN_DATA_DIRECTORY: dataDir } +export async function getMutagenEnv({ dataDir, logLevel }: MutagenEnvValues, log: Log): Promise { + const sshPath = await getMutagenSshPath(log) + if (sshPath) { + log.debug(`Mutagen will be used with the faux SSH transport located in ${sshPath}`) + } + const env: MutagenEnv = { MUTAGEN_DATA_DIRECTORY: dataDir, MUTAGEN_SSH_PATH: sshPath } if (!!logLevel) { env.MUTAGEN_LOG_LEVEL = logLevel } - if (!!sshPath) { - env.MUTAGEN_SSH_PATH = sshPath - } return env } diff --git a/core/src/plugins/kubernetes/commands/sync.ts b/core/src/plugins/kubernetes/commands/sync.ts index ec182536f8..993e057ee6 100644 --- a/core/src/plugins/kubernetes/commands/sync.ts +++ b/core/src/plugins/kubernetes/commands/sync.ts @@ -87,7 +87,7 @@ export const syncPause: PluginCommand = { await mutagen.exec({ cwd: dataDir, log, - env: getMutagenEnv({ dataDir }), + env: await getMutagenEnv({ dataDir }, log), args: ["sync", "pause", sessionName], }) } @@ -133,7 +133,7 @@ export const syncResume: PluginCommand = { await mutagen.exec({ cwd: dataDir, log, - env: getMutagenEnv({ dataDir }), + env: await getMutagenEnv({ dataDir }, log), args: ["sync", "resume", sessionName], }) } @@ -148,7 +148,7 @@ async function getMutagenSyncSessions({ mutagen, dataDir, log }: { mutagen: Plug const res = await mutagen.exec({ cwd: dataDir, log, - env: getMutagenEnv({ dataDir }), + env: await getMutagenEnv({ dataDir }, log), args: ["sync", "list", "--template={{ json . }}"], }) return parseSyncListResult(res)