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
684 stars 31 forks source link

Can not find task-runner.json when running dotnet husky run on Windows #42

Closed sayowayah closed 2 years ago

sayowayah commented 2 years ago

Version

0.4.2

Details

Hello! I have Husky.Net set up working great on my Mac with VS Code. However, my teammates using Visual Studio 2022 on Windows can't get our pre-commit hooks to work.

When I try dotnet husky run from PowerShell on Windows, I get an error message saying "Can not find task-runner.json" even though the file is there right next to pre-commit in the .husky folder. I've tried dotnet husky uninstall then dotnet husky install then dotnet huksy run with the default task-runner.json contents and get the same error.

My directory setup is a solution with multiple projects in their own folders. Husky.NET's .husky folder is at the root. My dotnet commands are all run from the root directory.

Any ideas? Thanks!

Steps to reproduce

On Windows 10 dotnet husky install dotnet husky run

Get error saying "Can not find task-runner.json"

alirezanet commented 2 years ago

Hi @sayowayah, What is the output of these two git commands on your Windows PC?

// Git Repo Path
git rev-parse --show-toplevel

// Husky Relative Path
git config --get core.hooksPath

I think your problem is related to git installation. loading the task-runner.json is simply a combination of these two commands (line 36): https://github.com/alirezanet/Husky.Net/blob/14d5a9abdbf48639ea81e2eee85bbe2324f03252/src/Husky/TaskRunner/HuskyTaskLoader.cs#L33-L40

sayowayah commented 2 years ago

Ah, thank you @alirezanet that helped! Turns out the directory structure wasn't a problem. It was an issue with my teammates using Chinese folder names which apparently Path.Combine does not like.

alirezanet commented 2 years ago

Ah, thank you @alirezanet that helped! Turns out the directory structure wasn't a problem. It was an issue with my teammates using Chinese folder names which apparently Path.Combine does not like.

Interesting... If you know any solution to support the Chinese language let me know. I'm not sure why Path.Combine doesn't work in this case! or I close the issue. thanks