Skip to content

Fix install.ps1 under irm | iex (drop [ValidateSet] on -Platform) - #1114

Open
EwoutH wants to merge 1 commit into
quarto-dev:mainfrom
EwoutH:bugfix/install-ps1-iex
Open

EwoutH wants to merge 1 commit into
quarto-dev:mainfrom
EwoutH:bugfix/install-ps1-iex

Conversation

@EwoutH

@EwoutH EwoutH commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

The documented Windows one-liner fails before installing anything:

PS> irm https://raw.githubusercontent.com/quarto-dev/q2/main/install.ps1 | iex
iex : The attribute cannot be added because variable Platform with value  would no longer be valid.
    + FullyQualifiedErrorId : ValidateSetFailure,Microsoft.PowerShell.Commands.InvokeExpressionCommand

Cause

Invoke-Expression doesn't run the text as a script with parameters; the param(...) block executes as ordinary variable declarations. The [ValidateSet('windows_amd64', 'windows_arm64')] on -Platform (added in v0.38.0) is then attached to a variable whose value is empty, which the set rejects. Minimal repro:

$s = "param([ValidateSet('a','b')][string]`$Platform)`n'ok'"
Invoke-Expression $s                 # ValidateSetFailure
& ([scriptblock]::Create($s))        # ok

CI didn't catch it because the nightly install smoke uses the scriptblock form (& ([scriptblock]::Create((irm …))) -Nightly), which binds parameters normally.

Changes

  • install.ps1: drop the [ValidateSet] and validate -Platform by hand after Die is defined, with the same accepted values and a clear error.
  • nightly.yml: add an install-smoke step (Windows PowerShell 5.1) that runs the literal irm … | iex one-liner. It installs the latest stable release to the default %USERPROFILE%\.local\bin and checks that q2.exe --version runs.

Verification (Windows 11, Windows PowerShell 5.1)

  • Get-Content -Raw install.ps1 | Invoke-Expression (with USERPROFILE pointed at a scratch dir): installs v0.42.0, checksum verified, q2 (quarto 2) 0.42.0.
  • -Platform bogus via the scriptblock form: q2 install: unknown -Platform 'bogus' (expected windows_amd64 or windows_arm64).
  • -Platform windows_amd64 -Dest <dir> via the scriptblock form: installs normally.

Until this lands, the workaround is & ([scriptblock]::Create((irm https://raw.githubusercontent.com/quarto-dev/q2/main/install.ps1))).

@posit-snyk-bot

posit-snyk-bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Invoke-Expression runs the script's param block as plain variable
declarations, so the [ValidateSet] on -Platform was applied to the
empty default and aborted the documented one-liner with "The attribute
cannot be added because variable Platform with value  would no longer
be valid." Validate -Platform by hand after the param block instead.

The nightly install smoke only ran the scriptblock form (which binds
parameters normally), so add a Windows PowerShell 5.1 step that runs
the literal `irm | iex` one-liner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@EwoutH
EwoutH force-pushed the bugfix/install-ps1-iex branch from 2c5b17c to fa3bbed Compare November 7, 2026 12:11
@cscheid
cscheid requested a review from cderv November 7, 2026 15:58
@cscheid

cscheid commented Nov 7, 2026

Copy link
Copy Markdown
Member

I'm going to let @cderv handle the review on this one.

This branch has not been deployed

No deployments
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.

3 participants