[Bug] `extract_dir` doesn't support spaces in path
Bug Report
Current Behavior
Spaces in extract_dir split a single argument into multiple arguments passed to 7z, which causes 7z to fail.
For example, highlight 4.16 requires "extract_dir": "highlight-4.16 -x64":
"path\to\7z.exe"
"x"
"C:\Users\galaxysnail\scoop\apps\highlight\4.16\highlight-4.16-x64.zip"
"-oC:\Users\galaxysnail\scoop\apps\highlight\4.16"
"-xr!*.nsis"
"-y"
"-ir!highlight-4.16"
"-x64\*"
Command Line Error:
Incorrect wildcard type marker
64\*
Expected Behavior
The directory should be extracted successfully.
Possible Solution
Wrap the extract_dir argument in quotes.
System details
Windows version: 10
OS architecture: 64bit
PowerShell version: 5.1.19041.5848
Additional software: 7z
Cannot reproduce.
PS C:\Users\WDAGUtilityAccount> scoop install highlight -u
WARN Scoop is out of date.
Installing 'highlight' (4.16) [64bit] from 'main' bucket
Loading highlight-4.16-x64.zip from cache
Checking hash of highlight-4.16-x64.zip ... ok.
Extracting highlight-4.16-x64.zip ... done.
Linking ~\中文\s p a c e\scoop\apps\highlight\current => ~\中文\s p a c e\scoop\apps\highlight\4.16
Creating shim for 'highlight'.
Creating shortcut for Highlight (highlight-gui.exe)
'highlight' (4.16) was installed successfully!
Notes
-----
You need to set the working directory of the shortcut to 'C:\Users\WDAGUtilityAccount\中文\s p a c
e\scoop\apps\highlight\current'
PS C:\Users\WDAGUtilityAccount> scoop cat highlight
{
"version": "4.16",
"description": "Converts source code to formatted text with syntax highlighting.",
"homepage": "http://www.andre-simon.de/doku/highlight/en/highlight.php",
"license": "GPL-3.0-only",
"notes": "You need to set the working directory of the shortcut to '$dir'",
"architecture": {
"64bit": {
"url": "http://www.andre-simon.de/zip/highlight-4.16-x64.zip",
"hash": "c8950a0660e528aec0094818ee2483ce0b433e14872dda597de66e2ea42b0419",
"extract_dir": "highlight-4.16 -x64"
},
"32bit": {
"url": "http://www.andre-simon.de/zip/highlight-4.16.zip",
"hash": "5aa5e1aa785a4cab82b1bca7e726b99aac77b3054a404c0d153c00a4e2d50f38",
"extract_dir": "highlight-4.16"
}
},
That's weird, I can still reproduce it with powershell 7.5.1.
Process Monitor shows that the cmdline is:
"path\to\7z.exe" x "C:\Users\galaxysnail\scoop\apps\highlight\4.16\highlight-4.16-x64.zip" -o"C:\Users\galaxysnail\scoop\apps\highlight\4.16" -xr!*.nsis -y -ir!highlight-4.16 -x64\*
It can be reproduced both windows powershell 5.1.26100.4061 and pwsh core 7.5.1 in my host OS.
But it cannot reproduce when I using Windows Sandbox, previous or now.
Host:
~
❯ scoop install highlight -u
WARN Scoop is out of date.
Installing 'highlight' (4.16) [64bit] from 'main' bucket
Loading highlight-4.16-x64.zip from cache
Checking hash of highlight-4.16-x64.zip ... ok.
Extracting highlight-4.16-x64.zip ... ERROR Exit code was 7!
Failed to extract files from C:\Users\humorce\scoop\apps\highlight\4.16\highlight-4.16-x64.zip.
Log file:
~\scoop\apps\highlight\4.16\7zip.log
Please try again or create a new issue by using the following link and paste your console output:
https://github.com/ScoopInstaller/Main/issues/new?title=highlight%404.16%3a+decompress+error
~
❯ powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows
PS C:\Users\humorce> scoop install highlight -u
WARN Scoop is out of date.
WARN Purging previous failed installation of highlight.
ERROR 'highlight' isn't installed correctly.
Removing older version (4.16).
'highlight' was uninstalled.
Installing 'highlight' (4.16) [64bit] from 'main' bucket
Loading highlight-4.16-x64.zip from cache
Checking hash of highlight-4.16-x64.zip ... ok.
Extracting highlight-4.16-x64.zip ... ERROR Exit code was 7!
Failed to extract files from C:\Users\humorce\scoop\apps\highlight\4.16\highlight-4.16-x64.zip.
Log file:
~\scoop\apps\highlight\4.16\7zip.log
Please try again or create a new issue by using the following link and paste your console output:
https://github.com/ScoopInstaller/Main/issues/new?title=highlight%404.16%3a+decompress+error
PS C:\Users\humorce> cat ~\scoop\apps\highlight\4.16\7zip.log
7-Zip 24.09 (x64) : Copyright (c) 1999-2024 Igor Pavlov : 2024-11-29
Command Line Error:
Incorrect wildcard type marker
64\*
PS C:\Users\humorce> scoop cat highlight
{
"version": "4.16",
"description": "Converts source code to formatted text with syntax highlighting.",
"homepage": "http://www.andre-simon.de/doku/highlight/en/highlight.php",
"license": "GPL-3.0-only",
"notes": "You need to set the working directory of the shortcut to '$dir'",
"architecture": {
"64bit": {
"url": "http://www.andre-simon.de/zip/highlight-4.16-x64.zip",
"hash": "c8950a0660e528aec0094818ee2483ce0b433e14872dda597de66e2ea42b0419",
"extract_dir": "highlight-4.16 -x64"
},
"32bit": {
"url": "http://www.andre-simon.de/zip/highlight-4.16.zip",
"hash": "5aa5e1aa785a4cab82b1bca7e726b99aac77b3054a404c0d153c00a4e2d50f38",
"extract_dir": "highlight-4.16"
}
},
Sandbox(VM):
PS C:\Users\WDAGUtilityAccount> scoop install highlight -u
Installing 'highlight' (4.16) [64bit] from 'main' bucket
Loading highlight-4.16-x64.zip from cache
Checking hash of highlight-4.16-x64.zip ... ok.
Extracting highlight-4.16-x64.zip ... done.
Linking ~\中文\s p a c e\scoop\apps\highlight\current => ~\中文\s p a c e\scoop\apps\highlight\4.16
Creating shim for 'highlight'.
Creating shortcut for Highlight (highlight-gui.exe)
'highlight' (4.16) was installed successfully!
Notes
-----
You need to set the working directory of the shortcut to 'C:\Users\WDAGUtilityAccount\中文\s p a c
e\scoop\apps\highlight\current'
PS C:\Users\WDAGUtilityAccount> scoop cat highlight
{
"version": "4.16",
"description": "Converts source code to formatted text with syntax highlighting.",
"homepage": "http://www.andre-simon.de/doku/highlight/en/highlight.php",
"license": "GPL-3.0-only",
"notes": "You need to set the working directory of the shortcut to '$dir'",
"architecture": {
"64bit": {
"url": "http://www.andre-simon.de/zip/highlight-4.16-x64.zip",
"hash": "c8950a0660e528aec0094818ee2483ce0b433e14872dda597de66e2ea42b0419",
"extract_dir": "highlight-4.16 -x64"
},
"32bit": {
"url": "http://www.andre-simon.de/zip/highlight-4.16.zip",
"hash": "5aa5e1aa785a4cab82b1bca7e726b99aac77b3054a404c0d153c00a4e2d50f38",
"extract_dir": "highlight-4.16"
}
},
- Relates to https://github.com/ScoopInstaller/Scoop/pull/5945
https://github.com/ScoopInstaller/Scoop/blob/b588a06e41d920d2123ec70aee682bae14935939/lib/core.ps1#L708-L714
Doesn't support a space with a slash or a hyphen right after it:
- [space]-
- [space]/
$regex = '(?<=(?<![:\w])[/-]\w+) | (?=[/-])'
$s = '-ir!highlight-4.16 x64\*'
$s -split $regex
$s = '-ir!highlight-4.16 -x64\*'
$s -split $regex
$s = '-ir!highlight-4.16-x64\*'
$s -split $regex
$s = '-ir!highlight-4.16 /x64\*'
$s -split $regex
$s = '-ir!highlight-4.16/x64\*'
$s -split $regex