ScoopInstaller / Scoop

A command-line installer for Windows.
https://scoop.sh
Other
20.46k stars 1.38k forks source link

[Bug] Error while trying to enable scoop config use_sqlite_cache (current implementation incompatible with PS 5.1) #6041

Closed mrplumber closed 1 week ago

mrplumber commented 2 weeks ago

Bug Report

Current Behavior

When trying to enable new SQLite cache feature with command scoop config use_sqlite_cache true got an error:

INFO  Initializing SQLite cache in progress... This may take a while, please wait.
Downloading SQLite 1.0.118...
Extracting SQLite 1.0.118...Scoop's Database cache requires the ADO.NET driver:
        http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
At C:\Users\Romas\scoop\apps\scoop\current\lib\database.ps1:61 char:13
+             throw "Scoop's Database cache requires the ADO.NET driver ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Scoop's Databas.../downloads.wiki:String) [], RuntimeExcept
   ion
    + FullyQualifiedErrorId : Scoop's Database cache requires the ADO.NET driver:
        http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

Expected Behavior

Obvious.

Additional context/output

Possible Solution

While debugging tried to manually follow commands in function Get-SQLite from lib/database.ps1 and got stuck there: https://github.com/ScoopInstaller/Scoop/blob/716b6db3ae55cd32eeb740243d688110a2728f83/lib/database.ps1#L29

Expand-Archive : .nupkg is not a supported archive file format. .zip is the only supported archive file format.
At line:1 char:1
+ Expand-Archive -Path .\sqlite.nupkg -DestinationPath .\sqlite -Force  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (.nupkg:String) [Expand-Archive], IOException
    + FullyQualifiedErrorId : NotSupportedArchiveFileExtension,Expand-Archive

Shouldn't this line: https://github.com/ScoopInstaller/Scoop/blob/716b6db3ae55cd32eeb740243d688110a2728f83/lib/database.ps1#L24 be like this:

$sqlitePkgPath = "$env:TEMP\sqlite.zip"

?

System details

Windows version: 10

OS architecture: 64bit

PowerShell version:

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      19041  4522

Additional software: [(optional) e.g. ConEmu, Git]

Scoop Configuration

{
    "last_update":  "2024-07-05T17:09:48.7354952+03:00",
    "alias":  {
                  "fs":  "scoop-fs"
              },
    "scoop_branch":  "master",
    "scoop_repo":  "https://github.com/ScoopInstaller/Scoop",
    "cat_style":  "auto"
}
mrplumber commented 2 weeks ago

Turns out it works with PowerShell 7.4 Still for compatibility's sake it seems reasonable to change the code as mentioned earlier.

mrplumber commented 2 weeks ago

Hit couple of more issues due to current implementation's incompatibility with PowerShell 5.1:

  1. Directory "$env:TEMP\sqlite" must be explicitly created (after https://github.com/ScoopInstaller/Scoop/blob/716b6db3ae55cd32eeb740243d688110a2728f83/lib/database.ps1#L27)

New-Item -Path $sqliteTempPath -ItemType Directory -Force | Out-Null

  1. Due to documented bug in PowerShell 5.1 line https://github.com/ScoopInstaller/Scoop/blob/716b6db3ae55cd32eeb740243d688110a2728f83/lib/database.ps1#L31 could be changed like this:

Get-ChildItem -Path "$sqliteTempPath\build\net45\*" -Recurse -Exclude '*.targets' | Move-Item -Destination $sqlitePath -Force

Scoop is being advertised as compatible with PowerShell 5.1 so these changes seem appropriate to implement.