# Install rive-cli from https://releases.rive.app/cli # # irm https://releases.rive.app/cli/install.ps1 | iex # # Optional env: # RIVE_VERSION pin a release (e.g. 0.1.0); default is the stream head # RIVE_STREAM stable (default), ea, or uat # RIVE_HOME install home (versions/, current, default); default $USERPROFILE\.rive # RIVE_INSTALL_DIR muxer path's directory; default $RIVE_HOME\bin # RIVE_BASE_URL override the CDN (tests / mirrors) # # Trust: SHA-256 the tarball against the manifest, extract only rive.exe, # reject a symlink. After that ~/.rive is user-owned. # # irm ... | iex evaluates this file in the caller's scope. Keep preference # assignments inside a child scope so they do not leak; $env:Path is # process-level and still updates the invoking session. & { $ErrorActionPreference = "Stop" $ProgressPreference = "SilentlyContinue" try { [Net.ServicePointManager]::SecurityProtocol = ` [Net.ServicePointManager]::SecurityProtocol -bor ` [Net.SecurityProtocolType]::Tls12 } catch { } if (-not $env:OS -or $env:OS -ne "Windows_NT") { throw "install.ps1 is for Windows. On macOS/Linux: curl -fsSL https://releases.rive.app/cli/install.sh | sh" } $BaseUrl = $env:RIVE_BASE_URL if (-not $BaseUrl) { $BaseUrl = "https://releases.rive.app/cli" } $BaseUrl = $BaseUrl.TrimEnd("/") $HomeDir = $env:RIVE_HOME if (-not $HomeDir) { $HomeDir = Join-Path $env:USERPROFILE ".rive" } $InstallDir = $env:RIVE_INSTALL_DIR if (-not $InstallDir) { $InstallDir = Join-Path $HomeDir "bin" } $ArtifactKey = "windows-x64" $PayloadName = "rive.exe" $Tar = Join-Path $env:SystemRoot "System32\tar.exe" if (-not (Test-Path $Tar)) { throw "install.ps1 needs System32 tar.exe" } function Test-SafeSegment([string]$Value) { return $Value -and $Value.Length -le 64 -and ($Value.IndexOf("..") -lt 0) -and ($Value -match '^[0-9A-Za-z._-]+$') } function Test-IsSymlink([string]$Path) { if (-not (Test-Path -LiteralPath $Path)) { return $false } $item = Get-Item -LiteralPath $Path -Force return [bool]($item.Attributes -band [IO.FileAttributes]::ReparsePoint) } function Install-Binary([string]$Src, [string]$Dest) { $destDir = Split-Path -Parent $Dest New-Item -ItemType Directory -Force -Path $destDir | Out-Null $tmp = "$Dest.new" Copy-Item -LiteralPath $Src -Destination $tmp -Force Move-Item -LiteralPath $tmp -Destination $Dest -Force } function Install-MuxerLink([string]$Payload, [string]$Muxer) { $destDir = Split-Path -Parent $Muxer New-Item -ItemType Directory -Force -Path $destDir | Out-Null $tmp = "$Muxer.new" if (Test-Path -LiteralPath $tmp) { Remove-Item -LiteralPath $tmp -Force } try { New-Item -ItemType HardLink -Path $tmp -Target $Payload -Force | Out-Null Move-Item -LiteralPath $tmp -Destination $Muxer -Force } catch { if (Test-Path -LiteralPath $tmp) { Remove-Item -LiteralPath $tmp -Force } Install-Binary $Payload $Muxer } } function Add-UserPath([string]$Dir) { $userPath = [Environment]::GetEnvironmentVariable("Path", "User") if ($null -eq $userPath) { $userPath = "" } $normalized = $Dir.TrimEnd("\") $already = $false foreach ($part in ($userPath -split ";")) { if ($part -and $part.TrimEnd("\") -ieq $normalized) { $already = $true break } } if (-not $already) { if ($userPath) { $userPath = "$Dir;$userPath" } else { $userPath = $Dir } [Environment]::SetEnvironmentVariable("Path", $userPath, "User") } $env:Path = "$Dir;$env:Path" } function Write-VersionFile([string]$Path, [string]$Version) { $dir = Split-Path -Parent $Path New-Item -ItemType Directory -Force -Path $dir | Out-Null $tmp = "$Path.new" Set-Content -LiteralPath $tmp -Value $Version -Encoding ascii Move-Item -LiteralPath $tmp -Destination $Path -Force } $tmp = Join-Path $env:TEMP ("rive-cli-install-" + [guid]::NewGuid().ToString("N")) New-Item -ItemType Directory -Force -Path $tmp | Out-Null try { $stream = if ($env:RIVE_STREAM) { $env:RIVE_STREAM } else { "stable" } if ($stream -notin @("stable", "ea", "uat")) { throw "RIVE_STREAM must be stable, ea, or uat (got '$stream')" } if ($env:RIVE_VERSION) { $manifestUrl = "$BaseUrl/v$($env:RIVE_VERSION)/manifest.json" } elseif ($stream -eq "stable") { $manifestUrl = "$BaseUrl/latest/manifest.json" } else { $manifestUrl = "$BaseUrl/$stream/manifest.json" } Write-Host "Fetching $manifestUrl" $manifestPath = Join-Path $tmp "manifest.json" Invoke-WebRequest -Uri $manifestUrl -OutFile $manifestPath -UseBasicParsing $manifest = Get-Content -LiteralPath $manifestPath -Raw -Encoding UTF8 | ConvertFrom-Json $version = [string]$manifest.version if (-not (Test-SafeSegment $version)) { throw "invalid version in manifest" } if ($env:RIVE_VERSION -and $version -ne $env:RIVE_VERSION) { throw "manifest version $version does not match requested $($env:RIVE_VERSION)" } $artProp = $manifest.artifacts.PSObject.Properties[$ArtifactKey] if (-not $artProp) { throw "manifest has no artifact '$ArtifactKey'" } $art = $artProp.Value $relPath = [string]$art.path $prefix = "v$version/" if (-not $relPath.StartsWith($prefix)) { throw "invalid artifact path in manifest" } $name = $relPath.Substring($prefix.Length) if (-not (Test-SafeSegment $name)) { throw "invalid artifact path in manifest" } $expectSha = ([string]$art.sha256).ToLowerInvariant() if ($expectSha -notmatch '^[0-9a-f]{64}$') { throw "invalid sha256 in manifest" } $tarballUrl = "$BaseUrl/$relPath" $archive = Join-Path $tmp "rive.tar.gz" Write-Host "Downloading rive $version ($ArtifactKey)" Invoke-WebRequest -Uri $tarballUrl -OutFile $archive -UseBasicParsing $gotSha = (Get-FileHash -Algorithm SHA256 -LiteralPath $archive).Hash.ToLowerInvariant() if ($gotSha -ne $expectSha) { throw "checksum mismatch for $tarballUrl`n expected $expectSha`n got $gotSha" } $list = & $Tar -tzf $archive if ($LASTEXITCODE -ne 0) { throw "could not list archive" } foreach ($member in $list) { $member = [string]$member if (-not $member) { continue } if ($member.StartsWith("/") -or $member.Contains("..") -or $member.Contains("\") -or $member.Contains(":")) { throw "archive contains an unsafe path: $member" } } & $Tar -xzf $archive -C $tmp -- $PayloadName if ($LASTEXITCODE -ne 0) { throw "tar extract failed" } foreach ($tree in @("docs", "samples")) { $present = $false foreach ($member in $list) { $member = [string]$member if ($member -eq $tree -or $member.StartsWith("$tree/")) { $present = $true break } } if ($present) { & $Tar -xzf $archive -C $tmp -- $tree if ($LASTEXITCODE -ne 0) { throw "tar extract failed" } } } $extracted = Join-Path $tmp $PayloadName if ((Test-IsSymlink $extracted) -or -not (Test-Path -LiteralPath $extracted -PathType Leaf)) { throw "tarball did not contain a '$PayloadName' binary" } foreach ($tree in @("docs", "samples")) { $treePath = Join-Path $tmp $tree if (Test-IsSymlink $treePath) { throw "refusing $tree`: not a directory" } if (Test-Path -LiteralPath $treePath -PathType Container) { $links = Get-ChildItem -LiteralPath $treePath -Recurse -Force -ErrorAction SilentlyContinue | Where-Object { $_.Attributes -band [IO.FileAttributes]::ReparsePoint } if ($links) { throw "refusing $tree containing symlinks" } } } $payload = Join-Path $HomeDir (Join-Path "versions" (Join-Path $version $PayloadName)) Install-Binary $extracted $payload foreach ($tree in @("docs", "samples")) { $src = Join-Path $tmp $tree if (Test-Path -LiteralPath $src -PathType Container) { $dest = Join-Path $HomeDir (Join-Path "versions" (Join-Path $version $tree)) if (Test-Path -LiteralPath $dest) { Remove-Item -LiteralPath $dest -Recurse -Force } Copy-Item -LiteralPath $src -Destination $dest -Recurse -Force } } $muxer = Join-Path $InstallDir $PayloadName Install-MuxerLink $payload $muxer Write-VersionFile (Join-Path $HomeDir "current") $version Write-VersionFile (Join-Path $HomeDir "default") $version Write-VersionFile (Join-Path $HomeDir "stream") $stream Add-UserPath $InstallDir Write-Host "Installed rive $version to $muxer" Write-Host "Version cache: $payload" Write-Host "" Write-Host "Get started:" Write-Host " rive create myproject scaffold a project in ./myproject" Write-Host " rive myproject preview it in a window, rebuilding on save" Write-Host " rive docs documentation; new to Rive, start here" Write-Host " rive samples runnable examples to copy from" Write-Host " rive --help every command and flag" Write-Host " rive login only for --publish, --rev and rive push" Write-Host "" Write-Host "For coding agents (Claude Code, Codex, Cursor and others):" Write-Host " npx skills add rive-app/skills" } finally { if (Test-Path -LiteralPath $tmp) { Remove-Item -LiteralPath $tmp -Recurse -Force } } }