winget-create icon indicating copy to clipboard operation
winget-create copied to clipboard

"ERROR: Path does not exist" when using trailing \ on manifest path (submit)

Open lars-nvhgroup opened this issue 2 years ago • 4 comments

Brief description of your issue

When using "wingetcreate submit "PATH_TO_MANIFEST" and PATH_TO_MANIFEST have a trailing \, it will fail with: "ERROR: Path does not exist".

Steps to reproduce

wingetcreate submit ".\manifests\x\XX\XXX\VERSION.NUMBERS\" fails while wingetcreate submit ".\manifests\x\XX\XXX\VERSION.NUMBERS" does not fail

Expected behavior

A trailing \ should be allowed, and not cause a path error.

Actual behavior

"ERROR: Path does not exist"

Environment

Windows Package Manager Manifest Creator v1.5.7.0

Windows Package Manager (Preview) v1.7.3172-preview
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.23606.1000
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.22.3172.0

Winget Directories
----------------------------------------------------------------------------------------------------- Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bb… User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bb… Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages
Installer Downloads                %USERPROFILE%\Downloads

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Enabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled

lars-nvhgroup avatar Dec 18 '23 09:12 lars-nvhgroup

This appears to be an issue in Command Prompt (cmd) and not PowerShell. Doing some google searches it seems that cmd uses the Microsoft C Runtime behavior for parsing command-line arguments that treats the final backslash as an escape character

A double quote mark preceded by a backslash (") is interpreted as a literal double quote mark (").

You would need to escape the final backslash to treat it as part of the path, or not use double quotes at all if possible. I'm not sure what winget-create could do to offer a better experience here...

In CMD, the following examples work

Escape final backslash

wingetcreate submit ".\manifests\x\xx\xxx\version\\"

Don't use quotes

wingetcreate submit .\manifests\x\xx\xxx\version\

Forward slashes

wingetcreate submit ./manifests/x/xx/xxx/version/

Forward slashes with quotes

wingetcreate submit "./manifests/x/xx/xxx/version/"

This doesn't work in CMD

Quoted backslash

wingetcreate submit ".\manifests\x\xx\xxx\version\"

All of the examples work in PowerShell tho.


References:

  • https://stackoverflow.com/questions/73771339/trailing-backslash-in-c-sharp-command-line-parameter-bug-or-feature
  • https://stackoverflow.com/questions/43359103/why-does-c-sharp-appear-to-partially-un-escape-command-line-arguments
  • https://stackoverflow.com/questions/71283820/directory-parameter-on-windows-has-trailing-backslash-replaced-with-double-quote
  • https://github.com/rust-lang/rust/issues/72653

mdanish-kh avatar Dec 18 '23 17:12 mdanish-kh

They don't work in PowerShell.

image

vedantmgoyal9 avatar Mar 12 '24 17:03 vedantmgoyal9

They don't work in PowerShell.

You might want to check if that is a valid path :eyes::

image

mdanish-kh avatar Mar 12 '24 17:03 mdanish-kh

It worked after reloading my VSCode window. Might be some bug with VSCode's terminal. Sorry for the trouble 🙏🏻

vedantmgoyal9 avatar Mar 12 '24 17:03 vedantmgoyal9