fix: use static URL in install script to support choco download --internalize#4
Open
LucaMoor wants to merge 1 commit into
Open
fix: use static URL in install script to support choco download --internalize#4LucaMoor wants to merge 1 commit into
LucaMoor wants to merge 1 commit into
Conversation
choco download --internalize does a static text scan for URLs and cannot evaluate PowerShell variables at scan time. The dynamic URL containing \\\ caused the internalizer to attempt fetching a literal 'v\' URL, resulting in a 404. - Replace the interpolated URL in chocolateyinstall.ps1 with a PLACEHOLDER_VERSION token - Update update.ps1 to rewrite the placeholder to the resolved version string alongside the existing checksum replacement This ensures every published .nupkg contains a fully static, resolvable URL such as: .../releases/download/v1.14.29/opencode-windows-x64.zip
Author
|
Fixes #3 |
Author
|
@itsrainingmani FYI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
choco download --internalizefails with a 404 when trying to internalize this package:The remote file either doesn't exist, is unauthorized, or is forbidden for url 'https://github.com/anomalyco/opencode/releases/download/v$env:chocolateyPackageVersion/opencode-windows-x64.zip'The Chocolatey internalizer performs a static text scan for URLs in the install script — it does not execute PowerShell. Because the download URL is built from a runtime variable (
), the internalizer tries to fetch the URL literally, withunresolved, and receives a 404.This is a documented limitation of the Chocolatey internalizer: "variables with methods" and dynamic URL construction cannot be automatically resolved.
Fix
Two changes:
tools/chocolateyinstall.ps1— replace the interpolated URL with aPLACEHOLDER_VERSIONtoken (same pattern already used for the checksum).update.ps1— rewrite the placeholder to the resolved version string alongside the existing checksum replacement, so every published.nupkgcontains a fully static URL likehttps://github.com/anomalyco/opencode/releases/download/v1.14.29/opencode-windows-x64.zip.This is consistent with how the checksum is already handled and requires no change to the release/publish workflow.