Repository navigation
Description
The problem
Hi,
I have a pre-commit hook and it works from the command line if I do
git add file1.py
git add file2.py
git commit -m "a message"
however if I run it from the desktop I get
Activating virtual environment...
.git/hooks/pre-commit: line 5: C:/Work/GitHubRepo/WatsonX/pilots/FK/orchestration/venv_fk_watsonx/Scripts/activate: No such file or directory
Failed to activate virtual environment. Commit aborted.
This is the same if Use the /c/Work path too
#!/bin/bash
echo "Activating virtual environment..."
#source /c/Work/GitHubRepo/WatsonX/pilots/FK/orchestration/venv_fk_watsonx/Scripts/activate
source C:/Work/GitHubRepo/WatsonX/pilots/FK/orchestration/venv_fk_watsonx/Scripts/activate
if [ $? -ne 0 ]; then
echo "Failed to activate virtual environment. Commit aborted."
exit 1
fi
echo "Running pybabel command as a pre-commit hook..."
pybabel init -D prompt -i locales/sv/prompt.pot -o locales/sv/LC_MESSAGES/prompt.po -l en -w 130
pybabel init -D prompt -i locales/en/prompt.pot -o locales/en/LC_MESSAGES/prompt.po -l en -w 130
if [ $? -ne 0 ]; then
echo "pybabel command failed! Commit aborted."
exit 1
fi
echo "Adding to commit"
git add locales/sv/LC_MESSAGES/prompt.po
git add locales/en/LC_MESSAGES/prompt.po
echo "pybabel command executed successfully. Proceeding with commit..."
exit 0
Release version
Version 3.4.8 (x64)
Operating system
Windows 11
Steps to reproduce the behavior
Use the pre-commit and it fails
Log files
No response
Screenshots
Additional context
No response
Yesterday we shipped GitHub Desktop 3.5.5-beta1 to our beta channel with improved support for hooks related to committing.
The support is experimental and currently limited to our beta channel. While we believe that this release resolved this issue we're looking for real-world feedback so if you have the ability we'd appreciate it if you could download our beta channel and give it a spin. Ensure the experimental hooks support it's enabled by going to Settings -> Git -> Hooks and making sure the "Load Git hook environment variables from shell" is ticked.

Activity
steveward commentedon Nov 8, 2024
@Nniol thanks for the issue. There are some known issues with hooks, since GitHub Desktop doesn't inherit the same environment. You can try running
github .from the command line to open GitHub Desktop, which sometimes gets things working. Let me know if that helps.Nniol commentedon Nov 11, 2024
@steveward
running
github .from the repo base dir on my drive made no difference, still got the same issueniik commentedon Jan 14, 2026
Yesterday we shipped GitHub Desktop 3.5.5-beta1 to our beta channel with improved support for hooks related to committing.
The support is experimental and currently limited to our beta channel. While we believe that this release resolved this issue we're looking for real-world feedback so if you have the ability we'd appreciate it if you could download our beta channel and give it a spin. Ensure the experimental hooks support it's enabled by going to Settings -> Git -> Hooks and making sure the "Load Git hook environment variables from shell" is ticked.