Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(versions): Get current version from failed installation if possible #4720

Merged
merged 4 commits into from
Feb 9, 2022

Conversation

niheaven
Copy link
Member

@niheaven niheaven commented Feb 7, 2022

Description

This PR changes some UX after #3721, which cause scoop reset <app> not works as before (some use cases that I missed)

  • lib\versions.ps1: Select-CurrentVersion() now get version from current folder or latest installed version
  • lib\install.ps1: ensure_none_failed() just reset failed app if it is installed successfully before
  • lib\core.ps1: failed() could figure out failed installation with new Select-CurrentVersion() function
  • libexec\scoop-list.ps1: Correctly mark failed app
  • libexec\scoop-install.ps1: Use ensure_none_failed() before installing apps
  • libexec\scoop-update.ps1: Use ensure_none_failed() before updating apps

Motivation and Context

How Has This Been Tested?

Remove current junction in 7zip

Before:

Get-ChildItem D:\Scoop\apps\7zip

    Directory: D:\Scoop\apps\7zip

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----            2022/2/8     1:01                21.07

❯ scoop list 7zip
Installed apps matching '7zip':

  7zip  *failed*
  7zip-zstd v21.03-v1.5.0-R2 [versions]

❯ scoop reset 7zip
ERROR '7zip' isn't installed

❯ scoop uninstall 7zip
ERROR '7zip' isn't installed correctly.
Removing older version (21.07).
'7zip' was uninstalled.

After:

Get-ChildItem D:\Scoop\apps\7zip

    Directory: D:\Scoop\apps\7zip

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----            2022/2/8     1:43                21.07

❯ scoop list 7zip
Installed apps matching '7zip':

  7zip 21.07 *failed* [main]
  7zip-zstd v21.03-v1.5.0-R2 [versions]

❯ scoop reset 7zip
Resetting 7zip (21.07).
Linking D:\Scoop\apps\7zip\current => D:\Scoop\apps\7zip\21.07
Creating shim for '7z'.
Creating shortcut for 7-Zip (7zFM.exe)
Persisting Codecs
Persisting Formats

# Remove `current` junction again
❯ scoop install 7zip
WARN  Repair previous failed installation of 7zip.
Resetting 7zip (21.07).
Linking D:\Scoop\apps\7zip\current => D:\Scoop\apps\7zip\21.07
Creating shim for '7z'.
Creating shortcut for 7-Zip (7zFM.exe)
Persisting Codecs
Persisting Formats
WARN  '7zip' (21.07) is already installed.
Use 'scoop update 7zip' to install a new version.

# Now remove `current` junction in `7zip` and all content under `7zip-zstd`
❯ scoop list 7zip
Installed apps matching '7zip':

  7zip 21.07 *failed* [main]
  7zip-zstd  *failed*

❯ scoop update 7zip-zstd
ERROR '7zip-zstd' isn't installed correctly.
INFO  Please reinstall it or fix the manifest.
Latest versions for all apps are installed! For more information try 'scoop status'

❯ scoop install 7zip-zstd
WARN  Purging previous failed installation of 7zip-zstd.
ERROR '7zip-zstd' isn't installed correctly.
'7zip-zstd' was uninstalled.
WARN  Repair previous failed installation of 7zip.
Resetting 7zip (21.07).
Linking D:\Scoop\apps\7zip\current => D:\Scoop\apps\7zip\21.07
Creating shim for '7z'.
WARN  Overwriting shim ('7z.exe' -> '7z.exe') installed from 7zip-zstd
Creating shortcut for 7-Zip (7zFM.exe)
Persisting Codecs
Persisting Formats
Installing '7zip-zstd' (v21.03-v1.5.0-R2) [64bit]
Loading 7z21.03-zstd-x64.exe from cache.
Checking hash of 7z21.03-zstd-x64.exe ... ok.
Extracting dl.7z ... done.
Linking D:\Scoop\apps\7zip-zstd\current => D:\Scoop\apps\7zip-zstd\v21.03-v1.5.0-R2
Creating shim for '7z'.
WARN  Overwriting shim ('7z.exe' -> '7z.exe') installed from 7zip
Creating shim for '7zG'.
Creating shortcut for 7-Zip (7zFM.exe)
'7zip-zstd' (v21.03-v1.5.0-R2) was installed successfully!

Checklist:

  • I have read the Contributing Guide.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.

@rashil2000
Copy link
Member

rashil2000 commented Feb 7, 2022

This also solves #4573

@rashil2000
Copy link
Member

And maybe #4474 and #4350 too?

@niheaven
Copy link
Member Author

niheaven commented Feb 8, 2022

This also solves #4573

#4573 is fixed here, but #4474 and #4350 need some other changes.

@niheaven
Copy link
Member Author

niheaven commented Feb 8, 2022

#4722 fixes #4350 and #4474

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants