Warning `WSL_E_DEFAULT_DISTRO_NOT_FOUND` on git hook
The problem
I'm testing git hooks for my Dart project, and I would need to run dart pub get.
As mentioned here, the same command runs inside dart test but when I'm running it by itself the error is thrown.
Quote
The dart command does this for test:
mit-macbookpro6:app1 mit$ rm pubspec.lock mit-macbookpro6:app1 mit$ dart test Resolving dependencies in /Users/mit/tmp/app1... (1.1s)
You can test it by simply removing lines 42 - 50:
#...
# Fetch packages
echo "Running dart pub get..."
dart pub get
if [ $? -ne 0 ]; then
echo "dart pub get failed."
echo "Please run 'dart pub get' in the project root."
exit 1
fi
#...
Output when I commit on GitHub Desktop:
Running pre-commit checks...
Running dart pub get...
Subsistema do Windows para Linux n�o tem distribui��es instaladas.
Use 'wsl.exe --list --online' para listar as distribui��es dispon�veis.
e 'wsl.exe --install <Distro>' para instalar.
As distribui��es tamb�m podem ser instaladas visitando a Microsoft Store:
https://aka.ms/wslstore
Error code: Bash/Service/CreateInstance/GetDefaultDistro/WSL_E_DEFAULT_DISTRO_NOT_FOUND
dart pub get failed.
Please run 'dart pub get' in the project root.
Here is my pre-commit hook:
#!/bin/sh
echo "Running pre-commit checks..."
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --type=bool hooks.allownonascii)
# Redirect output to stderr.
exec 1>&2
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi
# Fetch packages
echo "Running dart pub get..."
dart pub get
if [ $? -ne 0 ]; then
echo "dart pub get failed."
echo "Please run 'dart pub get' in the project root."
exit 1
fi
# Dart analyzer no errors should be found
echo "Running Dart analyzer..."
dart analyze
if [ $? -ne 0 ]; then
echo "Dart analyzer found issues."
echo "Please run 'dart analyze' in the project root."
exit 1
fi
# Dart tests should pass
echo "Running Dart tests..."
dart test . 1>/dev/null
# Print files that failed tests
if [ $? -ne 0 ]; then
echo "Dart tests failed."
echo "Please run 'dart test' in the project root."
exit 1
fi
# Dart fix --apply then any changed files should be added to the commit
echo "Running Dart fix..."
dart fix --apply .
git add .
# Dart format then any changed files should be added to the commit
echo "Running Dart format..."
dart format .
git add .
# return 0 to indicate that everything went well
echo "Pre-commit checks passed."
exit 0
Release version
Version 3.3.5 (x64)
Operating system
Windows 11 Pro
Steps to reproduce the behavior
- Install dart
- Run
dart create test - Add the
pre-commitscript pre-commit.txt and remove.txt, or copy the code above, inside.git/hooks/folder - Make a change somewhere
- Try to commit with GitHub Desktop
Log files
2023-12-11.desktop.production.log
Screenshots
Additional context
No response
Thanks for the issue @FMorschel. Are you using this repository in Windows Subsystem for Linux? There are some known problems around hooks with WSL in GitHub Desktop.
The specific error you mentioned does seem to be an issue that was reported in the WSL repository as well: https://github.com/microsoft/WSL/issues/9338
Hi again! No, I'm not. I'm running on my Windows 11 Pro machine. Simply running a change in this project (must run git config --local core.hooksPath .hooks/ to make sure the hook is set up right)
I had previously installed WSL, but I have uninstalled everything that contains the words "Linux" or "WSL" at the "Add or Remove Programs" as well as the actual distro I was using (Ubuntu). No use.
I'll take some time later to see if following this tutorial could solve my problem. But it would still not work if I had it simply installed (I already did the first two steps on that tutorial).
Update: even after doing as the above-mentioned tutorial asked, still not working.
Same for me, wrote pre-commit hook to enforce branch naming policy, when tried to give a shot with gh desktop got below error: Running from Windows 10 without any Linux subsystem GH desktop Version 3.3.6 (x64)