nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.83k stars 2.38k forks source link

Failed run nx graph after other nx command in Dockerfile #27582

Open uginroot opened 3 months ago

uginroot commented 3 months ago

Current Behavior

An error occurs during graph construction if this command is called immediately after any other nx command

Expected Behavior

There shouldn't be any errors

GitHub Repo

https://github.com/uginroot/nx-graph-problem

Steps to Reproduce

  1. Create dockerfile
  2. Run any nx command
  3. Run nx graph --file graph.json

Nx Report

#9 [5/7] RUN yarn nx report
#9 0.407 yarn run v1.22.19
#9 0.432 $ /app/node_modules/.bin/nx report
#9 1.452 
#9 1.453  NX   Report complete - copy this into the issue template
#9 1.453 
#9 1.453 Node           : 18.15.0
#9 1.453 OS             : linux-x64
#9 1.453 Native Target  : x86_64-linux
#9 1.453 yarn           : 1.22.19
#9 1.453 
#9 1.453 nx             : 19.6.2
#9 1.453 @nx/js         : 19.6.2
#9 1.453 @nx/workspace  : 19.6.2
#9 1.453 @nx/devkit     : 19.6.2
#9 1.453 @nrwl/tao      : 19.6.2
#9 1.453 typescript     : 5.5.4
#9 1.453 
#9 1.462 Done in 1.06s.

Failure Logs

TypeError: Cannot read properties of undefined (reading 'split')
    at handleProjectGraphError (/app/node_modules/nx/src/project-graph/project-graph.js:158:37)
    at Object.generateGraph (/app/node_modules/nx/src/command-line/graph/graph.js:179:57)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.handler (/app/node_modules/nx/src/command-line/graph/command-object.js:21:30)
error Command failed with exit code 1.

Package Manager Version

No response

Operating System

Additional Information

If you run RUN rm -rf /tmp/* after the first nx command, everything works.

m3Lith commented 1 month ago

See https://github.com/nrwl/nx/issues/27078#issuecomment-2257890424