COPY fails to copy from \\wsl$

samintz

Scott Mintz
May 20, 2008
1,488
15
Solon, OH, USA
I cannot copy files from a WSL2 folder. I mapped drive W: to \\wsl$\Ubuntu-20.04. NET USE says it's a Plan 9 Network Provider.

Code:
$ copy * i:\.RaRecovery\
W:\git\Platform\Boot\ICE3\Utility\DebugJumper\ICE3_Eval\PostBuild_baremetal_lp64_el3_release\Firmware\PM.cms => I:\.RaRecovery\PM.cms
TCC: (Sys) The request was aborted.
W:\git\Platform\Boot\ICE3\Utility\DebugJumper\ICE3_Eval\PostBuild_baremetal_lp64_el3_release\Firmware\DebugJumper.cms => I:\.RaRecovery\DebugJumper.cms
TCC: (Sys) The request was aborted.
     0 files copied       2 failed

The copy succeeds from Explorer.
TCC 26.02.41 x64 Windows 10 [Version 10.0.19041.450]
TCC Build 41 Windows 10 Build 19041[/code]
 

samintz

Scott Mintz
May 20, 2008
1,488
15
Solon, OH, USA
You can copy data from Windows into your WSL environment because your drives show up in /mnt/. For example, drive C: is /mnt/c.

Copying in the other direction can be done by copying from \\wsl$. From your bash prompt, you can type "explorer.exe ." and it will launch Explorer with the path to your current folder.
 

samintz

Scott Mintz
May 20, 2008
1,488
15
Solon, OH, USA
WSL1 uses files that are directly accessible from Windows - e.g. C:\Users\mintz\AppData\Local\lxss. But WSL2 files are inside of a VHDX file.
C:\Users\mintz\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx
 

samintz

Scott Mintz
May 20, 2008
1,488
15
Solon, OH, USA
You can tell which WSL you're running by running: wsl -l -v
Code:
$ wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu-20.04           Running         2
  docker-desktop-data    Running         2
  Legacy                 Stopped         1
  Ubuntu                 Stopped         1
  docker-desktop         Running         2
 
May 20, 2008
11,288
95
Syracuse, NY, USA
I can do this (snipped) with TCC:

Code:
\\wsl$\ubuntu> dir

 Directory of  \\wsl$\ubuntu\*

2020-10-16  21:27         <DIR>    .
2020-10-16  21:27         <DIR>    ..
2019-07-04  00:51         <DIR>    bin
2019-05-21  10:42         <DIR>    boot
2020-10-16  21:27         <DIR>    dev

But I don't **SEE** WSL$\Ubuntu anywhere. l should I? And If I issue explorer.exe in bash (from any directory) explorer opens in my documents folder.
 
May 20, 2008
11,288
95
Syracuse, NY, USA
Here, this is cmd;

Code:
v:\> copy \\wsl$\ubuntu\home\vefatica\.bashrc
        1 file(s) copied.

And these are TCC.

Code:
\\wsl$\ubuntu\home\vefatica> copy .bashrc v:\
\\wsl$\ubuntu\home\vefatica\.bashrc => V:\.bashrc
TCC: (Sys) The request was aborted.
     0 files copied       1 failed

\\wsl$\ubuntu\home\vefatica> v:

v:\> copy \\wsl$\ubuntu\home\vefatica\.bashrc v:\
\\wsl$\ubuntu\home\vefatica\.bashrc => V:\.bashrc
TCC: (Sys) The request was aborted.
     0 files copied       1 failed
 
  • Like
Reactions: samintz

samintz

Scott Mintz
May 20, 2008
1,488
15
Solon, OH, USA
1602901191591.png

1602901144982.png
 
May 20, 2008
11,288
95
Syracuse, NY, USA
Mine's a tad different but it is WSL2.

Windows 10 Linux Subsystem
vefatica@jj
BUILD: 18363
BRANCH: 19h1_release
RELEASE: Ubuntu 18.04.2 LTS
KERNEL: Linux 4.19.128-microsoft-standard
UPTIME: 0d 0h 3m

I can get here:

1602901672051.png


via a back door ... go there with TCC and do "explorer ." or (plugin) "shellex ." and also by typing the location in explorer's location bar. But I can't find a way to get there from "This PC" by pushing buttons.

I don't have WSL$ or Ubuntu in explorer's Network folder. Do you?
 
May 20, 2008
11,288
95
Syracuse, NY, USA
After those commands, I see this. But there's nothing **IN** Network. I never see anything in Network, even when my old computer is on (and networked).

1602955982454.png
 
May 20, 2008
11,288
95
Syracuse, NY, USA
File copies in TCC are done with the Windows API (CopyFileEx), so that's apparently either broken or deliberately doesn't support wsl copies. Only Microsoft knows for sure, and they didn't document it.
It works in this very simple form.

Code:
    BOOL bCancel;
    if ( CopyFileEx(L"\\\\wsl$\\ubuntu\\home\\vefatica\\.bashrc", L"v:\\.bashrc", NULL, 0, &bCancel, 0) == 0 )
        wprintf(L"LE = %lu\n", GetLastError());

That's in a project called "Sleep" and

Code:
d:\projects2019\sleep\x64\release> dir /k /m v:\.bashrc
TCC: (Sys) The system cannot find the file specified.
 "V:\.bashrc"

d:\projects2019\sleep\x64\release> Sleep.exe

d:\projects2019\sleep\x64\release> dir /k /m v:\.bashrc
2020-10-17  14:53           3,789  .bashrc
 
May 20, 2008
11,288
95
Syracuse, NY, USA
I'm getting really bizarre results. In a nutshell ...

1. This works.

Code:
BOOL bCancel;
CopyFileEx(L"\\\\wsl$\\ubuntu\\home\\vefatica\\.bashrc", L"v:\\.bashrc", NULL, NULL, &bCancel, 0);

2. This fails.

Code:
    WCHAR    szSrc[MAX_PATH]  = L"\\\\wsl$\\ubuntu\\home\\vefatica\\.bashrc",
            szDest[MAX_PATH] = L"v:\\.bashrc";
    BOOL bCancel;
    CopyFileEx(szSrc, szDest, NULL, NULL, &bCancel, 0)'

3. And (most bizarre) if both of the above appear in the source, both fail!

In all failing cases, GetLastError() is 1235 ("The request was aborted.").

Here's some source in case anyone wan't to play with it.

Code:
#include <Windows.h>
#include <stdio.h>

INT wmain(INT argc, WCHAR **argv)
{
    WCHAR    szSrc[MAX_PATH]  = L"\\\\wsl$\\ubuntu\\home\\vefatica\\.bashrc",
            szDest[MAX_PATH] = L"v:\\.bashrc";
    BOOL bCancel;

    if ( CopyFileEx(L"\\\\wsl$\\ubuntu\\home\\vefatica\\.bashrc", L"v:\\.bashrc", NULL, NULL, &bCancel, 0) == 0 )
        wprintf(L"1 - LE = %lu\n", GetLastError());

    //if ( CopyFileEx(szSrc, szDest, NULL, NULL, &bCancel, 0) == 0 )
    //    wprintf(L"2 - LE = %lu\n", GetLastError());

    return 0;
}
 
May 20, 2008
11,288
95
Syracuse, NY, USA
Hmmm! My fault, I guess. If I set bCancel = FALSE before each call to CopyFileEx, everything works (makes sense, eh?).

This little test works fine with wsl$ paths.

Code:
#include <Windows.h>
#include <stdio.h>

INT wmain(INT argc, WCHAR **argv)
{
    if ( argc < 3 )
        return 1;
    BOOL bCancel;
    if ( !CopyFileEx(argv[1], argv[2], NULL, NULL, &(bCancel = FALSE), 0) )
        wprintf(L"LE = %lu\n", GetLastError());
    return 0;
}
 
Aug 23, 2010
635
9
Microsoft treating network names ending with $ as "system" names and won't show them in explorer.
F.e. you could create a network share named "mystuff$" and it will never appear in explorer, but will be visible in more honest programs (Far manager's Network browser plugin will show them as "hidden shares", for example).
"\\wsl$\" is another example of the same principle. This is a fake/special name for a local network service provided by the WSL2 host process, which exports all running VMs' root filesystems as network shares.
 
Similar threads
Thread starter Title Forum Replies Date
S WAD FTP copy fails in 16.00.25 Support 24
M WAD Copy command fails rather weirdly... Support 2
S WAD COPY from FTP site fails in 14.03.51 Support 9
C Copy (sys) error Support 3
Alpengreis Fixed Crash after copy dialog with big TCC.exception.log Support 5
vefatica Copy/Paste anomaly Support 4
D Documentation Typo in COPY help Support 0
D Differences between TCC and CMD with COPY /b Support 4
fpefpe copy /u and timestamps Support 4
M Strange error messages from TCC in FTP copy Support 7
G TCMD crash when copy Support 3
Alpengreis How to? Copy DIRs with attributes ... Support 4
E Text copy bug Support 1
Alpengreis [TCMD v25.00.24] Problem with copy and paste and the # char via mouse in TCC Support 6
fpefpe copy/cat Support 7
K copy /w slow relative to robocopy /mir Support 0
Jay Sage Problem with Context Menu Copy+Paste+Run Key Assignment Support 7
K "copy /z /w" command not deleting read-only files in destination Support 10
K copy changing destination current directory Support 1
D Keystroke to copy previous argument Support 3
A How to? Copy+Paste in TCMD tabs with Ctrl-Shift-Ins? Support 5
RChrismon How to? Copy TCMD.INI to New Version Support 7
R How to? Append files in multiple subfolders using copy? Support 8
Dick Johnson COPY /u (?) Support 9
fpefpe Documentation copy /u Support 7
R How to? copy /q ABC.txt + DEF.txt is appending hex 1A Support 8
D copy /g only shows transfer rate Support 1
J Error "Contents lost before copy" Support 3
B Can copy command concatenate multiple mp3 files Support 2
rps Documentation "Copy+Paste+run" question Support 2
kb6ojs Make /G parameter persistent in COPY/MOVE command? Support 4
fpefpe How to? copy / exclude Support 2
fpefpe robocopy -- copy /w Support 8
C copy /w /p prompts for deletion, but ... Support 3
D Fixed Copy Support 1
fpefpe Documentation copy/move using /c or /u Support 2
samintz WAD Copy/append adds a character Support 3
P Simple RegEx copy Support 9
fromano Fixed COPY ... TO ... crashing Support 3
Alpengreis How to? Copy & Paste without linebreak within TCMD Support 13
D COPY returns ERRORLEVEL 2 Support 5
mdwyer TCC 13 COPY: specified network name is no longer available. Support 5
CWBillow Copy a tree Support 17
J junction copy/move handling Support 6
vefatica Fixed COPY /S ftp://... Support 1
C WAD copy /u ftp local with Timeout? Support 5
D How to? Unregister a copy of Take command Support 1
vefatica FTP copy interrupted Support 2
C How to? COPY ftp folder query Support 7
R How to? TCC 16.03: copy a file to the clipboard? Support 10

Similar threads