jstarks / npiperelay

npiperelay allows you to access Windows named pipes from WSL
MIT License
660 stars 71 forks source link

npiperelay creates terminal window every time it is invoked from WSL2 #23

Closed Vulp-OS closed 1 year ago

Vulp-OS commented 2 years ago

The Problem

On the new version of the Windows Insider Preview for Windows 11 (10.0.22518.1000), WSL2 is fully installed and maintained via the windows store app. Something about this change (either the version of windows or the new WSL version) causes the npiperelay application to launch new windows every time it is invoked.

This occurs regardless of if the default Terminal app is set to "Windows Console Host" or "Windows Terminal".

Windows, WSL2/g, & Kernel version info

WSL version: 0.50.2.0 Kernel version: 5.10.74.3 WSLg version: 1.0.29 Windows version: 10.0.22518.1000 WIndows Terminal version: 1.11.2921.0

Backstory and use case

I'm using this as directed by the WSL2 workaround specified at: https://github.com/rupor-github/wsl-ssh-agent

My shell rc file contains:

# Set up SSH Agent Compatibility with Windows
export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock
ss -a | grep -q $SSH_AUTH_SOCK
if [ $? -ne 0   ]; then
    rm -f $SSH_AUTH_SOCK
    ( setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"$HOME/winhome/.wsl/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork & ) >/dev/null 2>&1
fi

When SSH activates, it uses this named pipe to interact with the Windows SSH Agent. I don't believe that the issue of a new terminal window appearing each time npiperelay is activated is related to this specific use-case, so I figured it was more appropriate to submit the issue here rather than on the wsl-ssh-agent repo.

mendhak commented 2 years ago

Can you check to see if this is the same issue you're describing? https://github.com/microsoft/WSL/issues/7568

Vulp-OS commented 2 years ago

This may be related. When running the example command referenced in your linked issue, a console window does open. Weirdly enough, after updating to the latest Windows 11 build, running npiperelay from WSL as described in my original description doesn't seem to open a new window anymore, even though I do get a console window opened when running the example command at microsoft/WSL#7568

So... Maybe my issue is fixed by the newer version of Windows 11? There's nothing about terminal, console, WSL, or background calls being fixed in the release notes though, so I'm not entirely sure.

Updated version info: WSL version: 0.50.2.0 Kernel version: 5.10.74.3 WSLg version: 1.0.29 Windows Version: 10.0.22526.1000 Windows Terminal Version: 1.11.3471.0

Vulp-OS commented 2 years ago

As an addendum to my above comment, it looks like I was incorrect in saying that npiperelay didn't open a new window any more. It seems to be a somewhat sporadic issue. That day, it wasn't opening a new window, but every day since, it has behaved as originally described. I'd wager that the issue is likely the same as microsoft/WSL#7568 and we can wait until that has some movement.

Vulp-OS commented 1 year ago

While the aforementioned WSL issue has not been closed, the issue of additional terminal windows opening when npiperelay was invoked has been resolved in more-recent versions of Windows. This issue can be considered resolved and be closed.