Skip to content

fix: use static URL in install script to support choco download --internalize#4

Open
LucaMoor wants to merge 1 commit into
itsrainingmani:mainfrom
LucaMoor:fix/internalize-static-url
Open

fix: use static URL in install script to support choco download --internalize#4
LucaMoor wants to merge 1 commit into
itsrainingmani:mainfrom
LucaMoor:fix/internalize-static-url

Conversation

@LucaMoor

Copy link
Copy Markdown

Problem

choco download --internalize fails 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, with unresolved, 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:

  1. tools/chocolateyinstall.ps1 — replace the interpolated URL with a PLACEHOLDER_VERSION token (same pattern already used for the checksum).
  2. update.ps1 — rewrite the placeholder to the resolved version string alongside the existing checksum replacement, so every published .nupkg contains a fully static URL like https://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.

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
@LucaMoor

Copy link
Copy Markdown
Author

Fixes #3

@LucaMoor

Copy link
Copy Markdown
Author

@itsrainingmani FYI

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.

1 participant