Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit hooks don't work on Windows with wsl2 installed. #1528

Closed
hamflx opened this issue Jan 29, 2023 · 1 comment · Fixed by #1532
Closed

Commit hooks don't work on Windows with wsl2 installed. #1528

hamflx opened this issue Jan 29, 2023 · 1 comment · Fixed by #1532
Labels
bug Something isn't working help wanted Extra attention is needed windows
Milestone

Comments

@hamflx
Copy link
Contributor

hamflx commented Jan 29, 2023

Describe the bug
Commit hooks don't work on Windows with wsl2 installed.

run cargo test -p asyncgit sync::hooks::tests::test_commit_msg_no_block_but_alter

[2023-01-29T07:41:54Z TRACE asyncgit::sync::hooks] run hook '"C:/Users/hamflx/AppData/Local/Temp/.tmp4nwh43/.git/hooks/commit-msg"' in '"C:/Users/hamflx/AppData/Local/Temp/.tmp4nwh43/"'
thread 'sync::hooks::tests::test_commit_msg_no_block_but_alter' panicked at 'assertion failed: `(left == right)`
  left: `NotOk("/bin/bash: line 1: C:/Users/hamflx/AppData/Local/Temp/.tmp4nwh43/.git/hooks/commit-msg: No such file or directory\n")`,  
 right: `Ok`', asyncgit\src\sync\hooks.rs:493:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It looks like gitui is using wsl's bash:

C:\> where bash
C:\Windows\System32\bash.exe

C:\> bash -c D:/tmp/echo_some_thing.sh
/bin/bash: line 1: D:/tmp/echo_some_thing.sh: No such file or directory

C:\> "C:\Program Files\Git\usr\bin\bash.exe" -c D:/tmp/echo_some_thing.sh
some thing

To Reproduce

run cargo test -p asyncgit sync::hooks::tests::test_commit_msg_no_block_but_alter on Windows(with WSL2 installed, and git bash not in PATH).

Expected behavior

unit test works.

Screenshots

Context (please complete the following information):

  • OS/Distro + Version: Windows 10 22H2 19045.2364
  • GitUI Version 0.22.1
  • Rust version: 1.66.1

Additional context

@hamflx hamflx added the bug Something isn't working label Jan 29, 2023
@hamflx
Copy link
Contributor Author

hamflx commented Jan 29, 2023

I'm trying to find git.exe, and using that to find bash.exe: hamflx@6480c01

For example, git.exe is located at C:\Program Files\Git\cmd\git.exe, then I remove cmd\git.exe from the path and add usr\bin\bash.exe, finally we get C:\Program Files\Git\usr\bin\bash. exe.

If this way is acceptable, I will make a pr.

@hamflx hamflx changed the title Commit hooks don't work with wsl2 on Windows. Commit hooks don't work on Windows with wsl2 installed. Jan 29, 2023
@extrawurst extrawurst added help wanted Extra attention is needed windows labels Jan 29, 2023
@extrawurst extrawurst added this to the v0.23 milestone Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants