nx icon indicating copy to clipboard operation
nx copied to clipboard

Nx operations hangs indefinitely

Open JbIPS opened this issue 1 year ago โ€ข 16 comments

Current Behavior

I'm trying to add Nx to my TS monorepo.

On first try, I installed it (pnpm i nx) but any run would hang on indefinitely. So I removed it, tried to reinstall it but now it hangs at postinstall

node_modules/.pnpm/[email protected]_@[email protected]/node_modules/nx: Running postinstall script

I tried other approach like pnpm dlx nx@latest init or even npx nx@latest init but it hangs at

 NX   ๐Ÿง Checking dependencies 

Also tried pnpm dlx create-nx-workspace from scratch but it hangs on the second step

Creating your workspace in test-nx

Expected Behavior

Inits operations should complete gracefully

GitHub Repo

No response

Steps to Reproduce

  1. pnpm dlx create-nx-workspace

Nx Report

โฏ pnpm dlx nx report                      
Packages: +115
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 123, reused 111, downloaded 4, added 115, done
.cache/pnpm/dlx/ogenweua4lihpne4pbq6bewrt4/1915f46eda6-1d714/node_modules/.pnpm/[email protected]/node_modules/nx: Running postinstall script, done in 373ms

(...and nothing for at least 20min)

Failure Logs

No response

Package Manager Version

PNPM v9.7.0 or NPM v10.5.0

Operating System

  • [ ] macOS
  • [X] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

A common logs I see with NODE_DEBUG=* on all the nx command is

MODULE 121282: RELATIVE: requested: ./error-types from parent.id /home/******/node_modules/.pnpm/[email protected]_@[email protected]/nod
e_modules/nx/src/project-graph/build-project-graph.js
MODULE 121282: looking for ["/home/*******/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/nx/src/project-graph"]
NET 121243: pipe true /tmp/plugin121243-0.sock
NET 121243: connect: attempting to connect to /tmp/plugin121243-0.sock:NaN (addressType: NaN)
MODULE 121282: Module._load REQUEST ./utils/project-configuration-utils parent: /home/*********/node_modules/.pnpm/[email protected]_@swc+
[email protected]/node_modules/nx/src/project-graph/build-project-graph.js
MODULE 121282: RELATIVE: requested: ./utils/project-configuration-utils from parent.id /home/*******/node_modules/.pnpm/[email protected].
7_@[email protected]/node_modules/nx/src/project-graph/build-project-graph.js
MODULE 121282: looking for ["/home/*********/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/nx/src/project-graph"]
NET 121243: createConnection [
  { path: '/tmp/plugin121243-1.sock' },
  [Function (anonymous)],
  [Symbol(normalizedArgs)]: true
]

The addressType: NaN caught my eyes but I don't know if it's relevant. But this logs keeps repeating until it hangs on

MODULE 121275: looking for ["/home/*******/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/nx/src/plugins/js"]
MODULE 121275: Module._load REQUEST child_process parent: /home/*******/node_modules/.pnpm/[email protected]_@[email protected]/node_modul
es/nx/src/plugins/js/index.js
MODULE 121275: load built-in module child_process
STREAM 121243: push <Buffer 7b 22 74 79 70 65 22 3a 22 6c 6f 61 64 2d 72 65 73 75 6c 74 22 2c 22 70 61 79 6c 6f 61 64 22 3a 7b 22 6e 61 6d 65 22 3a 2
2 6e 78 2f 6a 73 2f 64 65 70 ... 205 more bytes>
TIMER 121243: unenroll: list empty
STREAM 121243: maybeReadMore read 0
STREAM 121243: read 0
STREAM 121243: need readable true
STREAM 121243: length less than watermark true
STREAM 121243: do read
NET 121243: _read - n 16384 isConnecting? false hasHandle? true

I tried emptying /tmp, restarting, nx clean but the issue persists

JbIPS avatar Aug 17 '24 07:08 JbIPS

Not sure if the issue is related, but I get a similar behavior when upgrading from NX 18 to NX 19. My installation gets stuck on the postinstall nx step forever. If I ignore the scripts when installing modules, subsequent nx commands get stuck as well.

Using: Node v18.16.0 PNPM 8.12.1 OS Sonoma 14.4.1 (23E224) Apple M1 Pro

cefeboru avatar Aug 19 '24 15:08 cefeboru

We have some members of our team experiencing this issue too, one reverted to the last version of nx we were on (19.2.3) to get around this fail to install. Would be great to get a fix for this.

DanLatimer avatar Aug 19 '24 18:08 DanLatimer

This occurs on create-nx-workspace for you? Which answers did you provide to the prompts? If possible, is there a repo that I can run nx init in to reproduce the issue?

Can you also see if any of these environment variables resolve the issue?

  • NX_DAEMON=false
  • NX_ISOLATE_PLUGINS=false

FrozenPandaz avatar Aug 19 '24 21:08 FrozenPandaz

It try create-nx-workspace with the env vars, same result

โฏ NX_DAEMON=false NX_ISOLATE_PLUGINS=false pnpm dlx create-nx-workspace
Packages: +56
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Progress: resolved 56, reused 55, downloaded 1, added 56, done

 NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

โœ” Where would you like to create your workspace? ยท test-nx
โœ” Which stack do you want to use? ยท none
โœ” Package-based monorepo, integrated monorepo, or standalone project? ยท integrated
โœ” Which CI provider would you like to use? ยท gitlab

 NX   Creating your v19.6.1 workspace.

โœ” Installing dependencies with pnpm
โ  Creating your workspace in test-nx
[Hangs indefinitely...]

I tried to use what seems like basic option to remove complexity but nothing changed.

JbIPS avatar Aug 19 '24 22:08 JbIPS

I have the same problem, both create-nx-workspace and nx migrate stop responding at postinstall.

The last version that worked is v19.4.4

MacBookPro intel cpu node: 20.16.0 pnpm: 9.6.0

blacksand avatar Aug 20 '24 06:08 blacksand

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! ๐Ÿ™

github-actions[bot] avatar Aug 28 '24 00:08 github-actions[bot]

I've suffered from this issue in bitbucket pipelines... ๐Ÿ˜• Sometimes it takes so many time to run postinstall

tonivj5 avatar Aug 28 '24 17:08 tonivj5

this is the same: https://github.com/nrwl/nx/issues/20270

Markus-Ende avatar Sep 03 '24 13:09 Markus-Ende

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! ๐Ÿ™

github-actions[bot] avatar Sep 11 '24 00:09 github-actions[bot]

Related issues:

  • https://github.com/nrwl/nx/issues/27056
  • https://github.com/nrwl/nx/issues/27220

90dy avatar Sep 23 '24 11:09 90dy

Similar issue: https://github.com/nrwl/nx/issues/28148

keriati avatar Sep 27 '24 13:09 keriati

I have the same problem with pnpm/npm/yarn. It works on my second mac with the exact same repository and node version, so it must be something outside the repository. - Thats prob the reason why no one can reproduce this bug.

NX 19.8.2, Node v20.17.0, PNPM 9.11.0, Apple M2 Pro

Edit: I have found a workaround: if i move the project to the /tmp folder and run pnpm i from there, it seems to work.

although i killed all processes accessing files in the project with lsof, the postinstall script only works in /tmp because the files are magically not locked in get_files. unfortunately the nx setup is too complex for me to debug it myself.

lennybakkalian avatar Oct 01 '24 09:10 lennybakkalian

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! ๐Ÿ™

github-actions[bot] avatar Oct 10 '24 00:10 github-actions[bot]

Up

tonivj5 avatar Oct 10 '24 04:10 tonivj5

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! ๐Ÿ™

github-actions[bot] avatar Oct 18 '24 00:10 github-actions[bot]

Bump

aagnone3 avatar Oct 18 '24 00:10 aagnone3

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! ๐Ÿ™

github-actions[bot] avatar Oct 27 '24 00:10 github-actions[bot]

Bump

aagnone3 avatar Oct 27 '24 00:10 aagnone3

bump macos 15.1 node 20.17 pnpm 9.12.0 nx 20.0.6

                                                                                                                             
/Users/marcin.repec/work/portal/node_modules/.pnpm/@[email protected]/node_modules/@nx/nx-darwin-arm64/nx.darwin-arm64.node:
        /Users/runner/work/nx/nx/build/target/aarch64-apple-darwin/release/deps/libnx.dylib (compatibility version 0.0.0, current version 0.0.0)
        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 2202.0.0)
        /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1226.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.61.1)
        /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)

marcin-repec avatar Oct 31 '24 12:10 marcin-repec

I think this workaround would also work here:

https://github.com/nrwl/nx/issues/28148#issuecomment-2390682884

keriati avatar Oct 31 '24 12:10 keriati

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! ๐Ÿ™

github-actions[bot] avatar Nov 08 '24 00:11 github-actions[bot]

Up

tonivj5 avatar Nov 08 '24 06:11 tonivj5

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! ๐Ÿ™

github-actions[bot] avatar Nov 16 '24 00:11 github-actions[bot]

Up

tonivj5 avatar Nov 16 '24 00:11 tonivj5

Known workarounds that probably solve this:

  • Remove from home directory any global .gitignore file (when used for dotfiles for example) suggested here: https://github.com/nrwl/nx/issues/28148#issuecomment-2480752077
  • Move the project out of the users home directory as suggested here: https://github.com/nrwl/nx/issues/28148#issuecomment-2390682884

keriati avatar Nov 17 '24 11:11 keriati

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! ๐Ÿ™

github-actions[bot] avatar Nov 25 '24 00:11 github-actions[bot]

Up

tonivj5 avatar Nov 25 '24 05:11 tonivj5

Something is definitely weird with the postinstall script. Here is how I fixed it for me, as it was hanging as well in Docker containers: https://github.com/nrwl/nx/issues/28148#issuecomment-2501589222

yduman avatar Nov 26 '24 23:11 yduman

This issue has been automatically marked as stale because no reproduction was provided within 7 days. Please help us help you. Providing a repository exhibiting the issue helps us diagnose and fix the issue. Any time that we spend reproducing this issue is time taken away from addressing this issue and other issues. This issue will be closed in 21 days if a reproduction is not provided. If a reproduction has been provided, please reply to keep it active. Thanks for being a part of the Nx community! ๐Ÿ™

github-actions[bot] avatar Dec 04 '24 00:12 github-actions[bot]

Up

tonivj5 avatar Dec 05 '24 14:12 tonivj5