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

Use Repair-WinGetPackageManager as a fallback install method #137066

Merged
merged 8 commits into from
Feb 1, 2024

Conversation

Trenly
Copy link
Contributor

@Trenly Trenly commented Jan 29, 2024

From @stephengillie's point in #136894, this PR entirely removes reduces the dependency of the SandboxTest script to check the hash of VCLibs, UI.Xaml, or WinGet. If the hash does not match or the file can't be downloaded, the SandboxTest script will now install the Microsoft.Winget.Client PowerShell module from the PSGallery and will use the Repair-WinGetPackageManager function to bootstrap and install WinGet instead of failing outright.

This ensures that if, or when, microsoft/winget-cli#3380 is completed, the SandboxTest script will not break. However, it does mean that it takes longer to bootstrap as the cmdlets will need to download VCLibs, UIXaml, and the correct version of WinGet every time the sandbox is opened - whereas the current script copies them from the disk of the user's device

cc @mdanish-kh / @stephengillie / @denelon

Microsoft Reviewers: Open in CodeFlow

@wingetbot
Copy link
Collaborator

Service Badge  Service Badge  

@Trenly Trenly changed the title Use Repair-WinGetPackageManager instead of managing dependencies dire… Use Repair-WinGetPackageManager instead of managing dependencies directly Jan 29, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Attention This work item needs to be reviewed by a member of the core team. label Jan 29, 2024
Copy link
Contributor

@mdanish-kh mdanish-kh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, I could not get the script to work on my VM. Didn't have much time to debug, but I suspect it's cause I messed something up in my VM. I'll see if I can find the time to debug, but I assume the script is working at your end, so I'm fine with the PR;

 ~/winget-pkgs .\Tools\SandboxTest.ps1 .\manifests\j\jqlang\jq\1.6\
--> Validating Manifest
Manifest validation succeeded.

Get-Content: C:\Users\User\winget-pkgs\Tools\SandboxTest.ps1:143
Line |
 143 |            $_.Value = ($((Get-Content "Env:$($_.Name)") + ";$($_.Value …
     |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot process argument because the value of argument "path" is not valid. Change the value of the "path" argument and run the operation again.

Tools/SandboxTest.ps1 Show resolved Hide resolved
Tools/SandboxTest.ps1 Outdated Show resolved Hide resolved
Tools/SandboxTest.ps1 Outdated Show resolved Hide resolved
* Fix ScriptAnalyzer warnings
* Add Try-Catch
* Update comment
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Attention This work item needs to be reviewed by a member of the core team. label Jan 30, 2024
@Trenly
Copy link
Contributor Author

Trenly commented Jan 30, 2024

For some reason, I could not get the script to work on my VM.

Seems it was an issue with variable parsing. Not sure why it wasn't showing up for me earlier, but this should be fixed now.

Copy link
Contributor

@mdanish-kh mdanish-kh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got the script running with the latest commits;

Just realized having these changes does mean we got rid of the local caching we used to do with the binaries; Each run is significantly slower now😥For validating manifests locally, I don't know if I value the script never breaking over script breaking once a while but allowing me to validate much faster every time. I'll leave this to you though

@Trenly
Copy link
Contributor Author

Trenly commented Jan 31, 2024

Got the script running with the latest commits;

Just realized having these changes does mean we got rid of the local caching we used to do with the binaries; Each run is significantly slower now😥For validating manifests locally, I don't know if I value the script never breaking over script breaking once a while but allowing me to validate much faster every time. I'll leave this to you though

That is a good point and is something I noticed as well.

I wonder if both could be implemented; Try using the local cache, and if theres a hash error, instead of throwing and exiting the script, use the Repair-WinGetPackageManager method

@Trenly Trenly marked this pull request as draft January 31, 2024 16:56
@mdanish-kh
Copy link
Contributor

I like the sound of that, but given my understanding of its implementation, that may mean users won't notice a hash mismatch as the script won't ever fail. If a user isn't aware of this context, they may never realize that the script is executing sub-optimally and don't report an issue to update the hashes.

Maybe we can have better messaging in the script to inform user of the hash mismatch and encourage the user to open an issue at https://github.com/microsoft/winget-pkgs?

@Trenly
Copy link
Contributor Author

Trenly commented Jan 31, 2024

I like the sound of that, but given my understanding of its implementation, that may mean users won't notice a hash mismatch as the script won't ever fail. If a user isn't aware of this context, they may never realize that the script is executing sub-optimally and don't report an issue to update the hashes.

Maybe we can have better messaging in the script to inform user of the hash mismatch and encourage the user to open an issue at https://github.com/microsoft/winget-pkgs?

I think that I can add a message either way

@Trenly Trenly changed the title Use Repair-WinGetPackageManager instead of managing dependencies directly Use Repair-WinGetPackageManager as a fallback install method Jan 31, 2024
@Trenly Trenly marked this pull request as ready for review January 31, 2024 18:44
@Trenly
Copy link
Contributor Author

Trenly commented Jan 31, 2024

@mdanish-kh - That was easier than I thought it would be, whenever you want to take a look at it. Easiest way to trigger the fallback is to manually set the hash to an incorrect value

Copy link
Contributor

@mdanish-kh mdanish-kh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this, just a few minor comments

Tools/SandboxTest.ps1 Show resolved Hide resolved
Tools/SandboxTest.ps1 Show resolved Hide resolved
@microsoft-github-policy-service microsoft-github-policy-service bot added the Moderator-Approved One of the Moderators has reviewed and approved this PR label Jan 31, 2024
@denelon denelon merged commit 8cefcfa into microsoft:master Feb 1, 2024
1 check passed
@Trenly Trenly deleted the SandboxRepair branch February 1, 2024 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Moderator-Approved One of the Moderators has reviewed and approved this PR Project-File
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants