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

Error "The command line is too long" when trying to run jscodeshift with a pattern match which returns many files #620

Open
darrenw-npi opened this issue Aug 8, 2024 · 1 comment

Comments

@darrenw-npi
Copy link

darrenw-npi commented Aug 8, 2024

I am getting "The command line is too long" when trying to run jscodeshift with a pattern match which returns 147 files. I am guessing this is because it passes all of the filenames on the command line. If I transform just a handful of files it works fine.
Can you let me know how I can resolve this issue please.
I am running this using Bash (MINGW64) on Windows 11. I can't use command prompt or PowerShell as they don't understand the globs like "**/*.spec.ts".

@darrenw-npi darrenw-npi changed the title Override batch size (CHUNK_SIZE in Runner.js) or number of workers with command line argument Error "The command line is too long" when trying to run jscodeshift with a pattern match which returns many files Aug 10, 2024
@Daniel15
Copy link
Member

Daniel15 commented Dec 9, 2024

This is a limitation of shells in Windows. You're right that the shell is expanding the glob and passing all the files on the command line. In bash/zsh/etc, you can run getconf ARG_MAX to get the maximum length of a command line. This returns 2097152 (2MB) on my Linux systems, but is often only 32000 (~32KB) in Windows bash shells. You can increase it using ulimit on Linux, but I'm not aware of a way to do that on Windows.

You could just pass a directory name and let jscodeshift traverse the files itself. That should work fine as long as your transform returns null if the file should not be transformed (this will keep the file as-is).

Alternatively, you could try using jscodeshift in WSL (Windows Subsystem for Linux), which should use the higher limits since it's a real(-ish) Linux environment rather than just some tools that have been ported to Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants