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: fix error when determining GOARCH in install.ps1 #3751

Merged
merged 2 commits into from
May 25, 2024

Conversation

bradenhilton
Copy link
Collaborator

@bradenhilton bradenhilton commented May 3, 2024

Fixes #3749.

@bradenhilton bradenhilton added the do not merge Do not merge label May 3, 2024
@bradenhilton
Copy link
Collaborator Author

@twpayne It would be useful to test the script with both pwsh and powershell. I am considering refactoring this PR to only include the change in 593dc29 and merging.

@bradenhilton bradenhilton changed the title chore: Run PowerShell install script workflow fix(install.ps1): fix error when determining GOARCH May 13, 2024
@bradenhilton bradenhilton removed the do not merge Do not merge label May 13, 2024
@bradenhilton bradenhilton marked this pull request as ready for review May 13, 2024 14:16
@bradenhilton
Copy link
Collaborator Author

bradenhilton commented May 13, 2024

docker run -it mcr.microsoft.com/windows:ltsc2019
Microsoft Windows [Version 10.0.17763.5696]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\>powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\> iex "&{$(irm 'https://raw.githubusercontent.com/twpayne/chezmoi/07f80802ad17b23fdac364541ee279252230418e/assets/scripts/install.ps1')} -d"
DEBUG: BinDir: C:\bin
DEBUG: Tag: latest
DEBUG: ChezmoiArgs:
DEBUG: tempDir: C:\Users\ContainerAdministrator\AppData\Local\Temp\91d3e380-fbd0-46cc-beea-705ca8fd63f7
DEBUG: goOS: windows
DEBUG: goArch: amd64
DEBUG: checking GitHub for tag latest
DEBUG: found tag v2.48.1 for latest
found version 2.48.1 for latest/windows/amd64
DEBUG: binarySuffix: .exe
DEBUG: archiveFormat: zip
DEBUG: goOSExtra:
DEBUG: archiveFilename: chezmoi_2.48.1_windows_amd64.zip
DEBUG: tempArchivePath: C:\Users\ContainerAdministrator\AppData\Local\Temp\91d3e380-fbd0-46cc-beea-705ca8fd63f7\chezmoi_2.48.1_windows_amd64.zip
DEBUG: downloading https://github.com/twpayne/chezmoi/releases/download/v2.48.1/chezmoi_2.48.1_windows_amd64.zip
DEBUG: downloading https://github.com/twpayne/chezmoi/releases/download/v2.48.1/chezmoi_2.48.1_checksums.txt as string
DEBUG: extracting C:\Users\ContainerAdministrator\AppData\Local\Temp\91d3e380-fbd0-46cc-beea-705ca8fd63f7\chezmoi_2.48.1_windows_amd64.zip to C:\Users\ContainerAdministrator\AppData\Local\Temp\91d3e380-fbd0-46cc-beea-705ca8fd63f7
DEBUG: binaryFilename: chezmoi.exe
DEBUG: tempBinaryPath: C:\Users\ContainerAdministrator\AppData\Local\Temp\91d3e380-fbd0-46cc-beea-705ca8fd63f7\chezmoi.exe
DEBUG: binary: C:\bin\chezmoi.exe
installed C:\bin\chezmoi.exe
DEBUG: removing C:\Users\ContainerAdministrator\AppData\Local\Temp\91d3e380-fbd0-46cc-beea-705ca8fd63f7

@bradenhilton bradenhilton force-pushed the ps1-workflow branch 2 times, most recently from 6df92b8 to 07f8080 Compare May 13, 2024 14:32
@bradenhilton bradenhilton changed the title fix(install.ps1): fix error when determining GOARCH fix: fix error when determining GOARCH in install.ps1 May 13, 2024
@twpayne
Copy link
Owner

twpayne commented May 24, 2024

Gentle ping on this. I think you're waiting for action from me to merge this, but I'm not sure what that action is :)

@bradenhilton
Copy link
Collaborator Author

I forgot about this.

I was actually hoping you or @pmolodo could test it, as I still can only reproduce the issue in a Docker container, but it's just dawned on me that I forgot to actually ask for it to be tested.

The old code tries the cross-platform solutions first, which we have since discovered can throw an error on some versions of PowerShell and/or Windows. It assumes that, if the cross-platform solutions fail, the script must be running under Windows PowerShell.

The new code adds a check for the Desktop version of PowerShell (Windows PowerShell), which is not cross-platform, so it should be reasonably safe to assume that the script is being ran on a Windows machine.

@bradenhilton bradenhilton merged commit 8f72b73 into twpayne:master May 25, 2024
24 checks passed
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.

Powershell one-line install on Windows 11 error - "You cannot call a method on a null-valued expression"
2 participants