Skip to content

Increase NX_SOCKET_DIR limit #27725

@wereHamster

Description

@wereHamster

Current Behavior

$ nx dev some-project

 NX   Attempted to open socket that exceeds the maximum socket length.


Set NX_SOCKET_DIR to a shorter path (e.g. /tmp/nx-tmp) to avoid this issue.
Pass --verbose to see the stacktrace.

My TMPDIR is /var/folders/7s/dlmpd6y94313nwn6q4mtwmf00000gn/T/nix-shell.exKnBn and workspace folder /Users/<username>/src/<workspace> (length 27). Together close to the Nx-imposed limit of 95 characters.

I have to manually set NX_SOCKET_DIR to a shorter path (eg. /tmp), then I can start using Nx.

Expected Behavior

Nx works in 'standard' situations with default TMPDIR and a workspace in a reasonable location.

GitHub Repo

No response

Steps to Reproduce

Be on MacOS, set TMPDIR to /var/folders/7s/dlmpd6y94313nwn6q4mtwmf00000gn/T/ (or similarly long path), have the workspace in a folder whose path length is >40 characters, try to run any Nx task.

Nx Report

Node           : 20.15.1
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 9.6.0

nx                 : 19.6.4
@nx/js             : 19.6.4
@nx/linter         : 19.6.4
@nx/eslint         : 19.6.4
@nx/workspace      : 19.6.4
@nx/devkit         : 19.6.4
@nx/esbuild        : 19.6.4
@nx/eslint-plugin  : 19.6.4
@nx/next           : 19.6.4
@nx/react          : 19.6.4
@nrwl/tao          : 19.6.4
@nx/web            : 19.6.4
@nx/webpack        : 19.6.4
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/next/plugin

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Relevant code which throws the error:

function assertValidSocketPath(path: string) {
if (path.length > 95) {
throw new Error(
[
'Attempted to open socket that exceeds the maximum socket length.',
'',
`Set NX_SOCKET_DIR to a shorter path (e.g. ${
isWindows ? '%TMP%/nx-tmp' : '/tmp/nx-tmp'
}) to avoid this issue.`,
].join('\n')
);
}
}

This seems to be a new behavior, it only started being an issue recently (maybe after my 19.6.3 -> 19.6.4 upgrade, but I'm not 100% certain).

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions