Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task format:write -> Error: Command line too long #2362

Closed
michelcve opened this issue Jan 22, 2020 · 5 comments · Fixed by #2913
Closed

Task format:write -> Error: Command line too long #2362

michelcve opened this issue Jan 22, 2020 · 5 comments · Fixed by #2913
Labels
community This is a good first issue for contributing outdated scope: misc Misc issues type: bug

Comments

@michelcve
Copy link

michelcve commented Jan 22, 2020

Expected Behavior

npm run format:write should complete without errors

Current Behavior

npm run format:write fails with error "Command line too long"

Failure Information (for bugs)

We have several long library + path + file names, that result in a command line for prettier that is too long.

NX already uses chunks (see: packages/schematics/src/command-line/format.ts), but the chuck size of 70 is too large for us.

When we decrease the chunk size to 50, all is well, and format:write runs happily.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Have very long library names + paths + files (in average above 118 characters, preferably longer), and at least 70 of 'm.
  2. Run npm run format:write
  3. Observe the "Command line too long" error

Context

I'm using NX 8.0, but verified that the latest code still uses a chunk side of 70.

Failure Logs

Full log available on request, but basically:

The command line is too long.
C:\Data\shared-workspace\node_modules\@nrwl\workspace\node_modules\yargs\yargs.js:1109
      else throw err
           ^
Error: Command failed: node "C:\Data\shared-workspace\node_modules\@nrwl\workspace\node_modules\prettier\bin-prettier.js" --write <lots and lots of files here>
    at checkExecSyncError (child_process.js:610:11)
    at Object.execSync (child_process.js:646:15)
    at write (C:\Data\shared-workspace\node_modules\@nrwl\workspace\src\command-line\format.js:84:25)
    at C:\Data\shared-workspace\node_modules\@nrwl\workspace\src\command-line\format.js:42:40
    at Array.forEach (<anonymous>)
    at Object.format (C:\Data\shared-workspace\node_modules\@nrwl\workspace\src\command-line\format.js:42:23)
    at Object.handler (C:\Data\shared-workspace\node_modules\@nrwl\workspace\src\command-line\nx-commands.js:72:98)
    at Object.runCommand (C:\Data\shared-workspace\node_modules\@nrwl\workspace\node_modules\yargs\lib\command.js:235:44)
    at Object.parseArgs [as _parseArgs] (C:\Data\shared-workspace\node_modules\@nrwl\workspace\node_modules\yargs\yargs.js:1022:30)
    at Object.get [as argv] (C:\Data\shared-workspace\node_modules\@nrwl\workspace\node_modules\yargs\yargs.js:965:21) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 8968,
  stdout: null,
  stderr: null
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sw@0.0.0 format:write: `nx format:write`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sw@0.0.0 format:write script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\****\AppData\Roaming\npm-cache\_logs\2020-01-22T09_18_07_616Z-debug.log
Process finished with exit code 1
@FrozenPandaz FrozenPandaz added the community This is a good first issue for contributing label Feb 28, 2020
@FrozenPandaz
Copy link
Collaborator

This is a relatively easy fix. Would someone from the community like to contribute a fix?

myspivey pushed a commit to myspivey/nx that referenced this issue Apr 24, 2020
Issue 2362 requests a length of 50 as 70 was still causing issues
this pr addresses that by reducing
the length to 50

ISSUES CLOSED: nrwl#2362
FrozenPandaz pushed a commit that referenced this issue Apr 29, 2020
…2913)

Issue 2362 requests a length of 50 as 70 was still causing issues
this pr addresses that by reducing
the length to 50

ISSUES CLOSED: #2362
@michelcve
Copy link
Author

@FrozenPandaz Thanks for the fix.

I was wondering though, wouldn't it be possible to do this a bit more intelligently, by calculating what the length would be, adding additional chucks as space permits?

@samk-ayyagari
Copy link

@FrozenPandaz I am getting this issue in 8.4.8, do I need to move to 9.3 version ?

@waterplea
Copy link

waterplea commented Nov 23, 2022

I'm getting this error too. It depends on file names, hardcoding 50 is not a proper fix unfortunately :(

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community This is a good first issue for contributing outdated scope: misc Misc issues type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants