sublime_merge
sublime_merge copied to clipboard
Support using git from Windows Subsystem for Linux (WSL)
Problem description
I would like for Sublime Merge to be able to use the git from Windows Subsystem for Linux (WSL). I am using Windows 10 and I have downloaded Sublime Merge for Windows. When I set Preferences>Advanced>Git Binary = C:\Users\Colten\AppData\Local\lxss\rootfs\usr\bin\git, the git pull commands (I assume all git commands) stop working and I see an error, "CreateProcess failed: 1% is not a valid Win32 application."
Preferred solution
I would very much like to be able to use the git from my WSL as it is where I commonly develop.
Alternatives
None that I can think of.
Screenshots
Right after I click the git pull (down arrow)
Resources https://docs.microsoft.com/en-us/windows/wsl/about https://github.com/microsoft/WSL
Use wsl git
as command.
So, I never got this working -- and I am now back for more troubleshooting.
I am now using WSL2.
It seems to me that using wsl git
does invoke the correct git binary, but there is an issue with file paths. Do you have any more ideas for me?
Has anyone gotten Sublime Merge working with the WSL2 git?
I don't think there is a trivial way to do this. In fact other editors with WSL support (e.g. vscode and pycharm) have to treat WSL like a remote machine, connect to it (you have to solve some issues with windows firewall etc.)
> Alternatives
None that I can think of.
That's not really correct: you can install Sublime Merge in WSL and use it from there. On the Windows side use e.g. VcXsrv. This is simple and works seamlessly. Or even simpler: run Sublime Merge in Windows and point it to the WSL repositories.
you can install Sublime Merge in WSL and use it from there. On the Windows side use e.g. VcXsrv.
You're absolutely right, and it gets better: WSL will get GUI support soon, you won't have to install X server anymore
run Sublime Merge in Windows and point it to the WSL repositories
It seems to me that what the OP is trying to do, is to have the git
binary working in this use case (which is impossibleif you see my previous comment)
Windows 10: 20H2 WSL 2 with Ubuntu sublime merge: 2059 stable
I was facing the same issue, had been using sublime merge & windows git binary and it was able to detect repository but wouldn't refresh/reflect the changes.
Found out that it works by refreshing or reloading. shortcut: ctrl+shift+H menu: tools->refresh.
I have been using this setup for a few weeks:
- install Sublime Merge into Windows
- open the repo via the synthetic network path e.g.
\\wsl.localhost\Ubuntu\home\matt\repo1
This plus the ctrl+shift+H shortcut has given me a nice visual "read only" experience. Trying to execute git
commands fails, as discussed above. My workaround was to manually execute the git
commands in the WSL terminal.
In an attempt to setup "write access" to the repos via Sublime Merge, I tried installing Sublime Merge into WSL2 via sudo apt-get install sublime-merge
. This seemed to work and a new double-clickable icon in C:\Users\matt\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Ubuntu
magically showed up after the install. This shortcut wraps the command C:\Windows\System32\wslg.exe ~ -d Ubuntu /opt/sublime_merge/sublime_merge
. However, when I double-click the icon or when I manually copy and paste that command into a cmd.exe prompt, nothing happens. No windows spawn or errors are emitted, just silence.
There's a well-known way of reaching the WSL2 Linux directories from Windows host: \\wsl$\Ubuntu-20.04\home\username\repo
(start with opening \\wsl$
in Windows Explorer)
Installing SublimeMerge to the host OS and opening the repo via such URI/path works pretty well in read/write mode. Except for, probably, handling the file execution flags.
Of course, the Windows version of Git executable is being used in this scenario and you'll need to sync configs somehow.
I haven't seen this solution here so I post mine: wslgit I installed that and then linked Sublime Merge git binary to wslgit.exe. It seems to work like a charm so far.
I am running:
Windows 11 Pro
Version 22H2
Installed on 5/16/2022
OS build 22622.575
Experience Windows Feature Experience Pack 1000.22634.1000.0
Windows Subsystem for Linux 2 (WSL2) is being used with Terminator as a window manager for bash shells.
I have some helper scripts:
name="smerge"
#!/bin/bash
DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
. "$DIR/interop.sh"
/mnt/c/Program\ Files/Sublime\ Merge/smerge.exe $(wslToUnc $1)
name="interop.sh"
wslToUnc () {
local path_arg=$1
if [[ "${path_arg}" == "" ]]; then
path_arg="."
fi
local full_path=$(readlink -e $path_arg)
#echo ${full_path} | sed 's:/home/matt:\\\\wsl.localhost\\Ubuntu\\home\\matt:' | sed 's:/:\\:g' | sed 's: :\\ :g'
echo '\\wsl.localhost\Ubuntu\'${full_path:1} | sed 's:/:\\:g' | sed 's: :\\ :g'
}
This allows me to start Sublime Merge from within my bash shell in Terminator with smerge .
This setup has been working nicely for a "read only" view of the repository. I can quickly look at the changes I have pending and then go back to the command line to write commits. ctrl+shift+h is useful to update Sublime Merge with the latest changes, since automatic updating doesn't work.
Yesterday, when I upgraded from build 2074 to build 2077 a new quirk was introduced that makes this workflow untenable because there are ~150 false positive "pending changes" that display in the summary view despite there being zero changes to display. I have tinkered with whitespace diff settings, but have not been able to resolve this. I will have to stop using Sublime Merge until I can figure out a solution.
It appears that all of the false positives have the executable bit set within WSL2. I'd guess that is confusing the "bundled" git that Sublime Merge is using. I also tried changing "bundled" to "system" and even "wsl git", but that did not work.
I installed wslgit as mentioned by @qherreros. That appears to make write access work, which is nice, but the executable-bit false positive clutter remains.
I was able to just install wslgit and point sublime merge to use it, so this can't be an incredibly difficult feature to implement.
I'd implement it myself, but Sublime Merge is closed source (boo! hiss!).
I was able to use Windows Sublime Merge just fine, pointed at the \\wsl$ directory, but it does not refresh automatically when things change. This is a recipe for disaster, so I installed the Ubuntu version via WSL 2. That was surprisingly easy! (It installs to /opt/sublime_merge). Unfortunately the Ubuntu UI is worse -- the font is tiny and I can't resize the columns. Still, pretty neat that it even works!