diff --git a/packages/nx/src/daemon/socket-utils.ts b/packages/nx/src/daemon/socket-utils.ts index 3cf2640613..c97f92f1e6 100644 --- a/packages/nx/src/daemon/socket-utils.ts +++ b/packages/nx/src/daemon/socket-utils.ts @@ -23,7 +23,7 @@ export const getForkedProcessOsSocketPath = (id: string) => { }; export const getPluginOsSocketPath = (id: string) => { - let path = resolve(join(getSocketDir(), 'plugin' + id + '.sock')); + let path = resolve(join(getSocketDir(true), 'plugin' + id + '.sock')); return isWindows ? '\\\\.\\pipe\\nx\\' + resolve(path) : resolve(path); }; diff --git a/packages/nx/src/daemon/tmp-dir.ts b/packages/nx/src/daemon/tmp-dir.ts index a865439486..0d163aef47 100644 --- a/packages/nx/src/daemon/tmp-dir.ts +++ b/packages/nx/src/daemon/tmp-dir.ts @@ -58,9 +58,11 @@ function socketDirName() { * We try to create a socket file in a tmp dir, but if it doesn't work because * for instance we don't have permissions, we create it in DAEMON_DIR_FOR_CURRENT_WORKSPACE */ -export function getSocketDir() { +export function getSocketDir(alreadyUnique = false) { try { - const dir = process.env.NX_DAEMON_SOCKET_DIR ?? socketDirName(); + const dir = + process.env.NX_DAEMON_SOCKET_DIR ?? + (alreadyUnique ? tmpdir : socketDirName()); ensureDirSync(dir); return dir; } catch (e) {