0

I currenlty run emacs-nox on WSL2. My workflow is as such:

[Gentoo Linux Host] –ssh–> [WSL2 Ubuntu 22.04.2 LTS (Windows VM)] –open–> [emacs] –edit–> /mnt/c/<Path>/<Files>

There is a significant performance increase to using the windows git.exe instead of the one on Ubuntu in wsl as I am working primarily in /mnt/c/<Path>/<Files>

I setup magit-git-executable to use windows git.exe as follows:

(when (string-match "-[Mm]icrosoft" operating-system-release)
  (setq magit-git-executable "/mnt/c/Program Files/Git/cmd/git.exe"))

It works great; however, the only thing I cannot seem to get working is magit-commit

I did manage to get it working without emacs however.

I created a script in wsl to convert the git.exe path argument to a wsl path

/usr/bin/wslemacs:

#!/bin/sh
WSL_PATH=$(wslpath -u "$1")
emacsclient "$WSL_PATH"

I then copied the command that magit-commit runs by grabbing it from M-x list-process in emacs and added -c "core.editor=wsl -e wslemacs".

git.exe --no-pager ... -c "core.editor=wsl -e wslemacs" commit --

When run from cmd.exe on windows it successfully opens COMMIT_EDITMSG in emacs running on wsl just as magit would.

I tried adding this to magit-git-global-arguments but still no luck.

I tried writing some output to a file from my wslemacs script to see if it was even being called when using magit-commit and it doesn't seem to be.

I tried using full paths to wsl and to my wslemacs script and still nothing works.

I was looking into magit-git.el and notice some stuff like magit-cygwin-mount-points that perhaps are hinting that something similar must be handled for wsl? I am really not sure.

What occurs when I try to commit in emacs with magit is it spawns a process to git.exe and it seems to just hang forever.

I tried looking at the with-editor-debug output but nothing jumps out at me. Happy to post if anyone thinks it would be helpful.

The only other thing I notice is that I think with-editor runs a separate emacs server than the one I was able to successfully commit when running git.exe directly from cmd.exe

Any help would be appreciated.

UPDATE I did a bit more digging. looks like this is the value of process-environment in the magit-start-process function in magit-process.el

"ALTERNATE_EDITOR=sh -c 'printf \"\\nWITH-EDITOR: $$ OPEN $0\\037 IN $(pwd)\\n\"; sleep 604800 & sleep=$!; trap \"kill $sleep; exit 0\" USR1; trap \"kill $sleep; exit 1\" USR2; wait $sleep'" "GIT_EDITOR=/usr/bin/emacsclient28 --socket-name=/tmp/emacs1000/server"
"LC_ALL"
"_=/usr/bin/emacs"
"OLDPWD=/mnt/c/TFSApps"
"SSH_TTY=/dev/pts/0"
"MSSQL_CLI_TELEMETRY_OPTOUT=True"
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/dev/kotlinc/bin:/home/dev/.local/bin:/opt/mssql-tools18/bin"
"XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop"
"SSH_CLIENT=172.24.64.1 1685 2222"
"GIT_EDITOR=wsl -e wslemacs"
"SHLVL=1"
"LPASS_AGENT_TIMEOUT=43200"
"USER=dev"
"LESSOPEN=| /usr/bin/lesspipe %s"
"TERM=dumb"
"LESSCLOSE=/usr/bin/lesspipe %s %s"
"SSH_CONNECTION=172.24.64.1 1685 172.24.66.118 2222"
"LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:"
"LANG=C.UTF-8"
"HOME=/home/dev"
"MOTD_SHOWN=pam"
"SCREENDIR=/home/dev/.screen"
"LOGNAME=dev"
"PWD=/mnt/c/TFSApps/Common/ORIFC/ORIFCXX"
"EDITOR=wsl -e wslemacs"
"JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/"
"SHELL=/bin/bash"

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.