win32yank icon indicating copy to clipboard operation
win32yank copied to clipboard

Using win32yank on WSL prints extra line on stdout

Open gglanzani opened this issue 8 years ago • 6 comments
trafficstars

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

gglanzani avatar May 03 '17 07:05 gglanzani

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?

equalsraf avatar May 03 '17 09:05 equalsraf

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.

gglanzani avatar May 03 '17 10:05 gglanzani

@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 avatar May 03 '17 21:05 equalsraf

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

equalsraf avatar May 03 '17 21:05 equalsraf

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

raffylopez avatar Jun 12 '17 23:06 raffylopez

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) 

mqudsi avatar Jul 14 '17 15:07 mqudsi