From 97ee5cd78c6fb51a24a3f256c76d059149a24f32 Mon Sep 17 00:00:00 2001 From: Jonathan Cammisuli <4332460+Cammisuli@users.noreply.github.com> Date: Wed, 8 Jan 2025 14:09:31 -0500 Subject: [PATCH] fix(core): update nx cloud bundle install directory logic --- packages/nx/src/nx-cloud/update-manager.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/nx/src/nx-cloud/update-manager.ts b/packages/nx/src/nx-cloud/update-manager.ts index ca8b01e030adb..9e402a37094ae 100644 --- a/packages/nx/src/nx-cloud/update-manager.ts +++ b/packages/nx/src/nx-cloud/update-manager.ts @@ -19,6 +19,7 @@ import { cacheDir } from '../utils/cache-directory'; import { createHash } from 'crypto'; import { TasksRunner } from '../tasks-runner/tasks-runner'; import { RemoteCacheV2 } from '../tasks-runner/default-tasks-runner'; +import { workspaceRoot } from '../utils/workspace-root'; interface CloudBundleInstall { version: string; @@ -150,7 +151,26 @@ export async function verifyOrUpdateNxCloudClient( nxCloudClient: require(currentBundle.fullPath), }; } -const runnerBundleInstallDirectory = join(cacheDir, 'cloud'); + +function getBundleInstallDefaultLocation() { + const legacyPath = join( + workspaceRoot, + 'node_modules', + '.cache', + 'nx', + 'cloud' + ); + + // this legacy path is used when the nx-cloud package is installed. + // make sure to reuse it so that we don't `require` different the client bundles + if (existsSync(legacyPath)) { + return legacyPath; + } else { + return join(cacheDir, 'cloud'); + } +} + +const runnerBundleInstallDirectory = getBundleInstallDefaultLocation(); function getLatestInstalledRunnerBundle(): CloudBundleInstall | null { if (!existsSync(runnerBundleInstallDirectory)) {