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

The command line is too long on Windows #655

Closed
ValentinGurkov opened this issue Mar 3, 2024 · 5 comments · Fixed by #666
Closed

The command line is too long on Windows #655

ValentinGurkov opened this issue Mar 3, 2024 · 5 comments · Fixed by #666
Labels
bug Something isn't working

Comments

@ValentinGurkov
Copy link

🔧 Summary

Hello,

I am testing the project with leftook instead of husky + lint-staged. I happen to have another formatting changes and the list of staged files is 365.

This seems to be already discussed inhttps://github.com//issues/471 and fixed in #541 but chunking of the input files did not happen.

I am currently testing with a very simple configuration like:

pre-commit:
    #piped: true
    #parallel: true
    commands:
        spellcheck:
            #priority: 1
            #glob: '*.{ts}'
            run: pnpm cspell --files {staged_files}

cspell can be replaced with another package like prettier for example. As long as staged_files are used and the number of files are long enough (I don't know where is the breaking point), this issue will occur.

Have I missed something to trigger the chunking?

Thanks.

Lefthook version

1.6.4

Steps to reproduce

  1. Be on windows
  2. Have a lot of files staged (in my example 365)
  3. Pass the staged files to a formatted or something similar in lefthook
  4. Observe the result

Expected results

The command should be split into multiple commands with each with a chunk of files.

Actual results

The command line is too long.

Possible Solution

Logs / Screenshots

Here is the error from pnpm lefthook run pre-commit --verbose. I have omitted the list of files, the project, and stashes. I did not see anything else in the log but it is possible it got trimmed in my terminal due to the long output.

⠴ waiting: spellcheckThe command line is too long.
┃  spellcheck ❯       


│ [lefthook] cmd: [git stash list]
│ [lefthook] dir: <project>
│ [lefthook] err: <nil>
│ [lefthook] out: <stashes here>
@ValentinGurkov ValentinGurkov added the bug Something isn't working label Mar 3, 2024
@ValentinGurkov ValentinGurkov changed the title The command line is too long. on Windows The command line is too long on Windows Mar 3, 2024
@mrexox
Copy link
Member

mrexox commented Mar 4, 2024

Hey! For Windows lefthook must split the long commands by 8000 symbols. Could you please check in the logs the length of the pnpm cspell --files ... command? It must be below 8000 symbols with spaces. If it's not, could you please tell what's the length of it?

@ValentinGurkov
Copy link
Author

ValentinGurkov commented Mar 4, 2024

Hey! For Windows lefthook must split the long commands by 8000 symbols. Could you please check in the logs the length of the pnpm cspell --files ... command? It must be below 8000 symbols with spaces. If it's not, could you please tell what's the length of it?

I piped the output onto a file, so things are easier to follow.
There seem the be 4 chunks with lengths:

  • chunk 1 - 7968
  • chunk 2 - 7929
  • chunk 3 - 7977
  • chunk 4 - 2364

The length starts from pnpm.. to the last provided file.

Chunks 1-3 trigger the error, even though they are below the 800 symbol limit. I've tried this with Git Bash, Command Prompt, and PowerShell.

I tried removing files from one of the chunks one by one and I got the command to execute at around 7262 symbols. I don't know whether this helps.

If I understand correctly, the way it is done in lint-staged, the limit is split by 2 https://github.com/lint-staged/lint-staged/blob/master/lib/index.js#L74, so the end result is more but smaller chunks.

Is this something that you believe can affect other people?

@mrexox
Copy link
Member

mrexox commented Mar 4, 2024

Thank you. Yes, probably it would be better to set the chunk size a bit smaller. Let me decrease the limit down to 7000 symbols. I hope this will help. Will release the fix ASAP

@mrexox
Copy link
Member

mrexox commented Mar 4, 2024

@ValentinGurkov , could you check 1.6.5 version?

@ValentinGurkov
Copy link
Author

@ValentinGurkov , could you check 1.6.5 version?

Thank you for responding this quickly, the fix worked wonderfully, even with more staged files!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants