jj describe uses invalid path when called from git bash on windows
Description
When calling jj describe on a windows machine from git bash it tries to use an invalid path containing a '?'. It seems to mix up windows/unix paths.
Steps to Reproduce the Problem
- Open git bash, navigate to a path of your choice (in my case
/c/work/git/testwhich corresponds toC:\work\git\test) -
jj git init -
jj config set --repo ui.editor vim -
jj describe
Note that the path passed to vim is /c/?C:workgittest.jjrepoeditor-IurIAZ.jjdescription instead of the expected /c/work/git/test/.jj/repo/editor....jjdescription.
With the editor set to notepad everything works as expected.
Expected Behavior
vim should be opened with the correct path, git bash seems to do some conversion so /c/work/git/... and C:\work\git\... both work from the terminal - I don't know whether they work when using e.g. std::process::Command.
Actual Behavior
vim is called with a mixed unix/windows path with what seems like encoding issues.
Specifications
- Platform: Windows 10
- Version: jj 0.16.0-2dcdc7fb3f20f262a73f52019f5a7b7e48fe069d
From discord comment:
I solved my problem by giving vim.exe an option(
--literal) to suppress wildcard expansion likeui.editor = [ "C:/Users/hymkor/scoop/apps/vim/current/gvim.exe" , "--literal" ].
Maybe this is the problem you faced? Not all Windows tools can process \\? path.
https://doc.rust-lang.org/std/fs/fn.canonicalize.html
I tried this and it does not help.
What you posted (\\?) does look like a UNC path (even though I've never seen it with a question mark before), which does not seem to be the issue here.
If you look at the path that vim is being called with it starts with /c/ in unix style (maybe due to being called in the git mingw shell), and then continues with ?C:workgit... which seems to be a messed up version of the windows path C:/work/git...
To check if vim is the issue here, I changed my config to call echo:
ui.editor = ["echo", "--literal"]
Then calling jj describe prints:
$ jj describe
--literal \?C:workgittest.jjrepoeditor-m5ehy4.jjdescription
Slightly different, but also messed up.
I don't know which version of echo is used, and if cmd.exe's echo supports escape syntax, but looks like \ is translated somewhere. If echo and vim are installed as MSYS binaries, MSYS might be the root cause.
This is due to Git Bash (MSYS?). I've personally encountered this too when running commands like less from a Git Bash installation from outside of it.
The issue with UNC paths in general is indeed an issue with some other programs - see #3986 - but specifically for this issue, I would personally recommend using a non-Git Bash shell / program for jj usage.
The problem should be mitigated by c256ad8a0aa43a1acb8a5e4c69ed2baf4f8976d3.