I'm trying to create a tarball of a directory using tar.exe on Windows 11. When I run in PowerShell or cmd:
tar -c -f file.tar directory\
I get the error
tar.exe: OCESSORS=24: Couldn't visit directory: No such file or directory
The name of the directory it couldn't visit varies between runs, but it seems to always grab some portion of an environment variable (e.g. env.PATH, etc), sometimes with the name of the directory stuck to the end of it.
It seems to work if I omit the trailing backslash:
tar -c -f file.tar directory
but I'm wondering what the issue is, particularly since PowerShell autocompletion adds the trailing backslash to the directory. I've read that trailing backslashes can cause issues in PowerShell but doesn't seem to apply in this situation since there are no special characters in the directory name, and in any case I don't see how it's grabbing a part of a random environment variable when it runs.