Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wsl 2 wslpath -m "No such file or directory" #34

Closed
k4fka opened this issue Aug 14, 2020 · 4 comments
Closed

wsl 2 wslpath -m "No such file or directory" #34

k4fka opened this issue Aug 14, 2020 · 4 comments

Comments

@k4fka
Copy link

k4fka commented Aug 14, 2020

Hi.
I'm running ubunu and WSL v2. When pasting an image from the clipboard I was getting an error thrown by the wslpath command. When this command is executed to resolve a path of a nonexistent file you get a "No such file or directory" error. This happens when trying to resolve the path AND the new image name.

I was able to work around this by resolving the folder path first and then appending the new image name

 33 function! s:SaveFileTMPWSL(imgdir, tmpname) abort
 34     let folder_path = substitute(system("wslpath -m ".a:imgdir), '\n\+$', '', '')
 35     let tmpfile = folder_path . '/' . a:tmpname . '.png'
 36
 37
 38     let clip_command = "Add-Type -AssemblyName System.Windows.Forms;"
 39     let clip_command .= "if ([Windows.Forms.Clipboard]::ContainsImage()) {"
 40     let clip_command .= "[Windows.Forms.Clipboard]::GetImage().Save(\\\""
 41     let clip_command .= tmpfile ."\\\", [System.Drawing.Imaging.ImageFormat]::Png) }"
 42     let clip_command = "powershell.exe -sta \"".clip_command. "\""
 43
 44     call system(clip_command)
 45     if v:shell_error == 1
 46         echo "error"
 47         return 1
 48     else
 49         return tmpfile
 50     endif
 51 endfunction
@ferrine
Copy link
Collaborator

ferrine commented Aug 15, 2020

Hi! So in WSL 2 the old method is changed, right? Can you please open a PR adding this check as an additional for WSL?

@ferrine
Copy link
Collaborator

ferrine commented Aug 24, 2020

related to #33

@hexcowboy
Copy link
Contributor

Want to try using this patch to see if it resolves your issues? If anyone with WSL wants to test please let me know so we can merge #36.

@ferrine
Copy link
Collaborator

ferrine commented Sep 22, 2020

I'll close the issue as the corresponding pr is merged. If any bug reappear, feel free to open

@ferrine ferrine closed this as completed Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants