Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to translate the wslpath /home/user/ to windows path

I use Linux subsystem of windows 10(windows 10 version 1803)

I can use command line:

user@laptop:~$ wslpath -w /c/
C:\

But when I try to use

user@laptop:~$ wslpath -w ~
wslpath: /home/user: Result not representable

Even I use:

user@laptop:~$ wslpath -w /home/user
wslpath: /home/user: Result not representable

why? how to translate the /home/user to windows path?

my home folder path in windows is C:\Users\winuser\AppData\Local\lxss\home

I expect some command line can give me return that string.

like image 303
user504909 Avatar asked Nov 26 '18 03:11

user504909


2 Answers

Updated guidance for users of Windows 10 1809 or later:

In Windows 10 1809, we (finally) shipped filesystem integration allowing you to access the files in your WSL distros from Windows via the \\wsl$ UNC path:

enter image description here

If you're interested in the details behind how this works, please visit this blog post: https://devblogs.microsoft.com/commandline/a-deep-dive-into-how-wsl-allows-windows-to-access-linux-files/

This now allows wslpath to provide a Windows-accessible path to files within your distro's filesystem:

enter image description here

In the up-coming Windows 10 May 2020 Update (2004), you won't have to remember the somewhat obscure \\wsl$\ UNC path - instead you'll just click on the Tux (Linux penguin) icon in your File Explorer:

enter image description here

Warning for WSL1 users:

Do not try to spelunk to the %localappdata%\lxss\... folders containing your WSL1 Linux files from Windows - there be dragons!

Please read this post: https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/

This guidance has not, and will not change, though it will become less important over time: In particular, WSL2 does not use %localappdata%\lxss - instead it stores your linux files within EXT4 formatted VHDX files delivering near-native IO performance for the distro's local filesystem.

like image 112
Rich Turner Avatar answered Nov 02 '22 04:11

Rich Turner


To convert a WSL Linux path to a Windows path use wlspath -w. For example:

$ wslpath -w /mnt/c/Users
C:\Users
$ wslpath -w /usr/bin
\\wsl$\Debian\usr\bin

(Yep, the answer is in the question, but some people, like me, are going to skip straight to the answers without reading the question.) The problem reported by the OP doesn't exist in WSL2.

like image 42
Samuel Avatar answered Nov 02 '22 04:11

Samuel