Closed daniel-shuy closed 9 months ago
Can you check if you can run it manually from outside of WSL using something like:
wsl -e /bin/bash -c "git commit -m 'My commit message.'"
This is more or less the command that gets run by wslgit
. If that does not work, you could check if it works when running an interactive shell (using the i
flag):
wsl -e /bin/bash -ic "git commit -m 'My commit message.'"
An interactive shell is usually required to apply your .bashrc
file, and for some commands (like push
, pull
, etc.) wslgit
automatically uses interactive shells. This can be configured as described here.
I got the same Permission denied
error for both
I managed to narrow down the issue. Somehow the PATH
is not set correctly when running in wslgit
/wsl -e
.
I am using asdf-nodejs to manage my Node.js versions, but its not working when running in wslgit
/wsl -e
because ~/.asdf/shims
is not in the PATH
.
Where does asdf
setup the correct PATH
? After a quick look in the documentation, it seems this is usually done in .bashrc
for the Bash shell. .bashrc
should be loaded by an interactive shell (with the i
flag) in most configurations.
You can check if .bashrc
is executed by putting something like echo "Executing .bashrc"
at the top of .bashrc
, and repeat the manual commands from above (for using wslgit
you must remove this output again, it will not work otherwise).
If there is no output, what distribution are you using? Do you have a .profile
, .bash_profile
or .bash_login
file in your home directory?
Ah, my bad, you hit the nail on the head, turns out I have both ~/.bashrc
and ~/.bash_profile
, which was causing the ~/.bash_profile
to be ignored. Thanks and sorry for the trouble
When attempting to run NPM scripts in a Git pre-commit hook,
wslgit
fails withPermission denied
.What's odd is I can run the NPM script manually in WSL with the same user used by
wslgit
(checked withecho $USER
in the pre-commit hook).