diff --git a/pkg/rancher-desktop/backend/lima.ts b/pkg/rancher-desktop/backend/lima.ts index cc752506d0b..c852d7a4faa 100644 --- a/pkg/rancher-desktop/backend/lima.ts +++ b/pkg/rancher-desktop/backend/lima.ts @@ -752,13 +752,24 @@ export default class LimaBackend extends events.EventEmitter implements VMBacken const VMNETDir = path.join(VMNET_DIR, 'bin'); const pathList = (process.env.PATH || '').split(path.delimiter); const newPath = [binDir, VMNETDir].concat(...pathList).filter(x => x); + const env = structuredClone(process.env); + + env.LIMA_HOME = paths.lima; + env.PATH = newPath.join(path.delimiter); + + // Override LD_LIBRARY_PATH to pick up the QEMU libraries. + // - on macOS, this is not used. The macOS dynamic linker uses DYLD_ prefixed variables. + // - on packaged (rpm/deb) builds, we do not ship this directory, so it does nothing. + // - for AppImage this has no effect because the libs are moved to a dir that is already on LD_LIBRARY_PATH + // - this only has an effect on builds extracted from a Linux zip file (which includes a bundled + // QEMU) to make sure QEMU dependencies are loaded from the bundled lib directory. + if (env.LD_LIBRARY_PATH) { + env.LD_LIBRARY_PATH = libDir + path.delimiter + env.LD_LIBRARY_PATH; + } else { + env.LD_LIBRARY_PATH = libDir; + } - // LD_LIBRARY_PATH is set for running from an extracted Linux zip file, that includes QEMU, - // to make sure QEMU dependencies are loaded from the bundled lib directory, - // LD_LIBRARY_PATH is ignored on macOS. - return { - ...process.env, LIMA_HOME: paths.lima, LD_LIBRARY_PATH: libDir, PATH: newPath.join(path.delimiter), - }; + return env; } protected static get qemuImgEnv() {