alirezanet / Husky.Net

Git hooks made easy with Husky.Net internal task runner! 🐶 It brings the dev-dependency concept to the .NET world!
https://alirezanet.github.io/Husky.Net/
MIT License
632 stars 29 forks source link

Chunks tasks can't load csx files in parallel. #93

Closed alirezanet closed 9 months ago

alirezanet commented 9 months ago

Discussed in https://github.com/alirezanet/Husky.Net/discussions/92

Originally posted by **AlaiyaNetwork** September 18, 2023 Hi all, I encountered a few errors when using pre-commit hook with a large number of files in a commit. 1 error: `fatal: Unable to create 'C:/WorkDirectory/.git/index.lock': File exists. Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue.` 2 error: `The process cannot access the file 'C:\WorkDirectory\.husky\csx\add-header-to-main.csx' because it is being used by another process.` The first error also occurs when using prettier, not only with custom scripts. But it doesn't cause the script to abort `[Husky] ⚡ Preparing task 'Run prettier'` `[Husky] ⚠️ The Maximum argument length '8191' reached, splitting matched files into 16 chunks` `[Husky] ⌛ Executing task 'Run prettier' ...` `fatal: Unable to create 'C:/WorkDirectory/.git/index.lock': File exists. Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue.` `[Husky] ✔ Successfully executed in 2 304ms` This is my custom script: `[Husky] ⚡ Preparing task 'Run add header to main script'` `[Husky] ⚠️ The Maximum argument length '8191' reached, splitting matched files into 9 chunks` `[Husky] ⌛ Executing task 'Run add header to main script' ...` `The process cannot access the file 'C:\WorkDirectory\.husky\csx\add-header-to-main.csx' because it is being used by another process.` `The process cannot access the file 'C:\WorkDirectory\.husky\csx\add-header-to-main.csx' because it is being used by another process.` `The process cannot access the file 'C:\WorkDirectory\.husky\csx\add-header-to-main.csx' because it is being used by another process.` `The process cannot access the file 'C:\WorkDirectory\.husky\csx\add-header-to-main.csx' because it is being used by another process.` `fatal: Unable to create 'C:/WorkDirectory/.git/index.lock': File exists. Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue.` `❌ Task 'Run add header to main script' failed in 487ms` `husky - pre-commit hook exited with code 1 (error)` Prettier task: `{ "name": "Run prettier", "command": "npx", "cwd": "Paylater.BackOffice.ReactApp", "args": [ "prettier", "--plugin", "prettier-plugin-organize-imports", "--ignore-unknown", "--write", "${staged}" ], "pathMode": "absolute" }` Maybe someone has encountered a similar problem and can give me a solution.
AlaiyaNetwork commented 9 months ago

I created test repo - https://github.com/AlaiyaNetwork/TestHuskyChunksError

This is funny console project create a lot of .cs files.

Husky have 3 tasks:

alirezanet commented 9 months ago

Hi @AlaiyaNetwork, Please try version v0.6.2, it should be fixed and let me know if you encountered any problem.