microsoft / microsoft/winget-cli

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

Open
#2,399 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Help-Wanted Issue-Bug
Dominant language
C++
Stars
26.4k
Forks
1.8k
Avg merge
1d 11h
Merged PRs (30d)
15

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no implementation files or tests. Reproduce the PowerShell command and inspect the CLI argument parsing for --override; done means the full path containing spaces remains part of the override value and is not treated as a separate package argument.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, powershell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.