equalsraf / win32yank

Windows clipboard tool
ISC License
444 stars 22 forks source link

Using win32yank on WSL prints extra line on stdout #3

Open gglanzani opened 7 years ago

gglanzani commented 7 years ago

Calling win32yank on WSL prints to stdout (before the clipboard is printed) the following line

Unable to translate current working directory. Using C:\Users\G

The tool is basically working when calling it from neovim inside Windows Subsystem from Linux. However that line gets printed everywhere, which is annoying :)

I've looked at the code, but there were no mentions of this so maybe it's rust doing this

equalsraf commented 7 years ago

There are a couple of similar issues around in github https://github.com/Microsoft/BashOnWindows/issues/2011

Likely some code is trying to figure out its current directory and having issues with the unexpected path and/or environment vars.

I wonder if setting $CD to a valid path works around it?

gglanzani commented 7 years ago

No, setting $CD doesn't help unfortunately :(

I was trying to make a shell script that changes folder to a Windows folder and then calls win32yank.exe, but I don't have much luck: the -o option pastes twice for example.

equalsraf commented 7 years ago

@gglanzani trying to reproduce this on Windows, but I do not get that message with any of the following

win32yank.exe -o
win32yank.exe -o --lf

I just updated windows so that might be the cause winver.exe reports OS build 15063.250

equalsraf commented 7 years ago

It seems this only happens when using a symlink to the actual binary, like the example in the neovim wiki.

raffylopez commented 7 years ago

Installing Xming for Windows, and then making sure to run export DISPLAY=:0 on the shell fixed this for me on neovim.

mqudsi commented 7 years ago

It's not a symlink issue and there's no straight-forward fix for this - it's an error generated by the WSL subsystem when cwd is inside the lxsys filesystem which isn't accessible from win32.

The fix is to call win32yank.exe via a Linux-side program/script which will filter that.

Here's my solution:

cat win32yank.exe

#!/bin/bash
win32yank.exe "$@" 2> >(sed -e '1h;2,$H;$!d;g' -r -e 's/Unable to translate[^\n]*\n//' 1>&2)