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

--override option does not correctly treat variables with spaces (like $Env:ProgramFiles)

Open manelrodero opened this issue 2 years ago • 0 comments

Brief description of your issue

While trying to override INSTALLDIR directory for Java JRE I've used the following command line:

winget.exe install --id Oracle.JavaRuntimeEnvironment --override "/s INSTALLCFG=`"$Env:TEMP\JavaRE64.cfg`" INSTALLDIR=`"$Env:ProgramFiles\Java\jre8`""

Argument parsing does not handle correctly $Env:ProgramFiles:

image

override arguments end at C:\Program and Files\Java\jre8 is treated as a Winget parameter instead of part of override.

So winget tries to install an application called Files\Java\jre8 that, obviously, does not exist ;-)

Steps to reproduce

Execute the following command:

winget.exe install --id Oracle.JavaRuntimeEnvironment --override "/s INSTALLDIR=`"$Env:ProgramFiles\Java\jre8`""

Expected behavior

Oracle JRE installed at C:\Program Files\Java\jre8.

Actual behavior

Winget complaints about inexistent Files\Java\jre8 application: No package found matching input criteria.

2022-07-30 18:14:03.644 [CORE] WinGet, version [1.3.2091], activity [{B6A2D391-2CC8-4A22-BAEF-9616EF4B5956}]
2022-07-30 18:14:03.644 [CORE] OS: Windows.Desktop v10.0.22000.795
2022-07-30 18:14:03.644 [CORE] Command line Args: "C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps\winget.exe" install --id Oracle.JavaRuntimeEnvironment --override "/s INSTALLDIR="C:\Program Files\Java\jre8"" -o c:\log
2022-07-30 18:14:03.644 [CORE] Package: Microsoft.DesktopAppInstaller v1.18.2091.0
2022-07-30 18:14:03.644 [CORE] IsCOMCall:0; Caller: winget-cli
2022-07-30 18:14:03.646 [CLI ] WinGet invoked with arguments: 'install' '--id' 'Oracle.JavaRuntimeEnvironment' '--override' '/s INSTALLDIR=C:\Program' 'Files\Java\jre8' '-o' 'c:\log'
2022-07-30 18:14:03.647 [CLI ] Found subcommand: install
2022-07-30 18:14:03.647 [CLI ] Leaf command to execute: root:install
2022-07-30 18:14:03.647 [CLI ] Executing command: install
2022-07-30 18:14:03.648 [REPO] GetCurrentSourceRefs: Source named 'microsoft.builtin.desktop.frameworks' from origin Default is hidden and is dropped.
2022-07-30 18:14:03.648 [REPO] Default source requested, multiple sources available, adding all to source references.
2022-07-30 18:14:03.648 [REPO] Adding to source references msstore
2022-07-30 18:14:03.648 [REPO] Adding to source references winget
2022-07-30 18:14:03.648 [REPO] Multiple sources available, creating aggregated source.
2022-07-30 18:14:03.648 [REPO] Adding to aggregated source: msstore
2022-07-30 18:14:03.648 [REPO] Sending http GET request to: https://storeedgefd.dsx.mp.microsoft.com/v9.0/information
2022-07-30 18:14:04.029 [REPO] Response status: 200
2022-07-30 18:14:04.029 [REPO] Sending http GET request to: https://storeedgefd.dsx.mp.microsoft.com/v9.0/information
2022-07-30 18:14:04.093 [REPO] Response status: 200
2022-07-30 18:14:04.093 [REPO] Adding to aggregated source: winget
2022-07-30 18:14:04.102 [CORE] Examining extension: PFN = Microsoft.Winget.Source_8wekyb3d8bbwe, ID = IndexDB
2022-07-30 18:14:04.102 [CORE] Found matching extension.
2022-07-30 18:14:04.116 [REPO] Opening SQLite Index for ImmutableRead at 'C:\Program Files\WindowsApps\Microsoft.Winget.Source_2022.730.1356.756_neutral__8wekyb3d8bbwe\Public\index.db'
2022-07-30 18:14:04.116 [SQL ] Opening SQLite connection: 'file:/C:/Program Files/WindowsApps/Microsoft.Winget.Source_2022.730.1356.756_neutral__8wekyb3d8bbwe/Public/index.db?immutable=1' [1, 40]
2022-07-30 18:14:04.117 [REPO] Opened SQLite Index with version [1.5], last write [2022-07-30 14:56:23.000]
2022-07-30 18:14:04.256 [REPO] Sending http POST request to: https://storeedgefd.dsx.mp.microsoft.com/v9.0/manifestSearch
2022-07-30 18:14:05.003 [REPO] Response status: 200
2022-07-30 18:14:05.012 [CLI ] No app found matching input criteria
2022-07-30 18:14:05.017 [CLI ] Terminating context: 0x8a150014 at D:\a\_work\1\s\external\pkg\src\AppInstallerCLICore\Workflows\WorkflowBase.cpp:32b

Environment

Windows Package Manager v1.3.2091
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22000.795
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.18.2091.0

manelrodero avatar Jul 30 '22 16:07 manelrodero