#Requires -Version 5.1 <# .SYNOPSIS Installs VSCodium (codium) — Free/Libre Open Source Software Binaries of VS Code. .DESCRIPTION Installs VSCodium on Windows following https://vscodium.com/ recommendations: 1) Primary: winget install -e --id VSCodium.VSCodium 2) Fallback: Downloads the latest VSCodiumUserSetup--.exe from GitHub Releases (VSCodium/vscodium) and runs silent user install. Supported architectures: - Windows x64 (AMD64 / Intel 64bit) - Windows ARM64 .PARAMETER AddToPath Whether to permanently add VSCodium's bin directory to User PATH. Default: $true .EXAMPLE .\install-codium.ps1 # One-liner install from remote (works on Windows 10+): powershell -ExecutionPolicy Bypass -c "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; $t=\"$env:TEMP\install-codium.ps1\"; iwr -useb 'https://gl.isitsoft.kr/publicproj/install-sh/-/raw/main/install-codium.ps1' -OutFile $t; & $t" .NOTES If execution policy error occurs: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser #> [CmdletBinding()] param( [bool] $AddToPath = $true ) Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' # Force TLS 1.2+ for HTTPS downloads (required on Windows 10 / PowerShell 5.1) [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 # ──────────────────────────────────────────── # Constants # ──────────────────────────────────────────── $REPO = "VSCodium/vscodium" $API_URL = "https://api.github.com/repos/$REPO/releases" $FALLBACK_TAG = "1.96.2.24355" $LOCAL_BIN = Join-Path $env:USERPROFILE ".local\bin" # ──────────────────────────────────────────── # Utility functions # ──────────────────────────────────────────── function Info { Write-Host "[INFO] $args" -ForegroundColor Cyan } function Warn { Write-Host "[WARN] $args" -ForegroundColor Yellow } function Success { Write-Host "[OK] $args" -ForegroundColor Green } function ErrExit { Write-Host "[ERROR] $args" -ForegroundColor Red; exit 1 } # ──────────────────────────────────────────── # Architecture detection # ──────────────────────────────────────────── function Get-CodiumArch { $envArch = $env:PROCESSOR_ARCHITEW6432 if (-not $envArch) { $envArch = $env:PROCESSOR_ARCHITECTURE } switch -Regex ($envArch) { '^AMD64$' { return "x64" } '^ARM64$' { return "arm64" } '^x86$' { return "ia32" } default { return "x64" } } } # ──────────────────────────────────────────── # Get latest release tag with assets from GitHub API # ──────────────────────────────────────────── function Get-LatestTag { Info "Fetching latest VSCodium release from GitHub API..." try { $releases = Invoke-RestMethod -Uri $API_URL -UseBasicParsing ` -Headers @{ 'User-Agent' = 'install-codium-ps1' } -TimeoutSec 15 $latest = $releases | Where-Object { $_.prerelease -eq $false -and $_.assets -and $_.assets.Count -gt 0 } | Select-Object -First 1 if ($latest -and $latest.tag_name) { return $latest.tag_name } } catch { Warn "GitHub API lookup failed: $_" } Warn "Using fallback release tag: $FALLBACK_TAG" return $FALLBACK_TAG } # ──────────────────────────────────────────── # Install via GitHub Releases UserSetup.exe (Fallback) # ──────────────────────────────────────────── function Install-FromGitHub { $arch = Get-CodiumArch $tag = Get-LatestTag Info "Target VSCodium release: $tag ($arch)" $exeName = "VSCodiumUserSetup-${arch}-${tag}.exe" $downloadUrl = "https://github.com/$REPO/releases/download/$tag/$exeName" $fallbackExe = "VSCodiumUserSetup-${arch}-${FALLBACK_TAG}.exe" $fallbackUrl = "https://github.com/$REPO/releases/download/$FALLBACK_TAG/$fallbackExe" $tmpDir = Join-Path $env:TEMP "codium_install_$(Get-Random)" New-Item -ItemType Directory -Path $tmpDir -Force | Out-Null try { $setupPath = Join-Path $tmpDir $exeName Info "Downloading installer: $downloadUrl" try { $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest -Uri $downloadUrl -OutFile $setupPath -UseBasicParsing $ProgressPreference = 'Continue' } catch { if ($downloadUrl -ne $fallbackUrl) { Warn "Primary download failed. Retrying with fallback version ($FALLBACK_TAG): $fallbackUrl" $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest -Uri $fallbackUrl -OutFile $setupPath -UseBasicParsing $ProgressPreference = 'Continue' } else { ErrExit "Failed to download VSCodium installer: $_" } } Info "Running VSCodium silent installer..." $installArgs = "/VERYSILENT /NORESTART /MERGETASKS=!runcode,addcontextmenufiles,addcontextmenufolders,associatewithfiles,addtopath" $proc = Start-Process -FilePath $setupPath -ArgumentList $installArgs -Wait -PassThru if ($proc.ExitCode -ne 0) { Warn "Installer exited with code $($proc.ExitCode)" } else { Success "VSCodium installed via official UserSetup installer." } } finally { if (Test-Path $tmpDir) { Remove-Item -Path $tmpDir -Recurse -Force -ErrorAction SilentlyContinue } } } # ──────────────────────────────────────────── # Add directory to User PATH # ──────────────────────────────────────────── function Add-ToUserPath { param([string]$Dir) $normalizedDir = $Dir.TrimEnd('\') if ($env:Path -notlike "*$normalizedDir*") { $env:Path = "$normalizedDir;$env:Path" Info "Added $normalizedDir to current session PATH." } $currentPath = [Environment]::GetEnvironmentVariable('Path', 'User') if (-not $currentPath) { $currentPath = '' } $dirs = @($currentPath -split ';' | Where-Object { $_ -ne '' }) $alreadyInPath = $false foreach ($d in $dirs) { if ($d.Trim().TrimEnd('\') -eq $normalizedDir) { $alreadyInPath = $true break } } if (-not $alreadyInPath) { $newPath = if ($currentPath) { "$normalizedDir;$currentPath" } else { $normalizedDir } [Environment]::SetEnvironmentVariable('Path', $newPath, 'User') Success "Added '$normalizedDir' to User PATH permanently." } else { Info "'$normalizedDir' is already in User PATH." } } # ──────────────────────────────────────────── # Main # ──────────────────────────────────────────── function Main { Info "===== VSCodium (codium) install script (Windows PowerShell) =====" $installed = $false # 1) Try official winget installation first (https://vscodium.com/#install-with-winget-windows) if (Get-Command winget -ErrorAction SilentlyContinue) { Info "Installing VSCodium via winget (VSCodium.VSCodium)..." try { & winget install -e --id VSCodium.VSCodium --accept-package-agreements --accept-source-agreements if ($LASTEXITCODE -eq 0 -or $LASTEXITCODE -eq -1978335189) { # -1978335189 = APPINSTALLER_CLI_ERROR_UPDATE_NOT_APPLICABLE (already installed) $installed = $true Success "VSCodium installed/verified via winget." } } catch { Warn "winget installation encountered an issue: $_" } } # 2) Fallback to GitHub Releases direct UserSetup installer if (-not $installed) { Info "Falling back to direct download from VSCodium GitHub Releases..." Install-FromGitHub } # 3) Locate codium bin directory and ensure PATH registration $candidateDirs = @( (Join-Path $env:LOCALAPPDATA "Programs\VSCodium\bin"), (Join-Path $env:ProgramFiles "VSCodium\bin"), (Join-Path ${env:ProgramFiles(x86)} "VSCodium\bin") ) $codiumBinDir = $null foreach ($dir in $candidateDirs) { if ($dir -and (Test-Path (Join-Path $dir "codium.cmd"))) { $codiumBinDir = $dir break } } if ($codiumBinDir -and $AddToPath) { Add-ToUserPath -Dir $codiumBinDir } Info "" Info "==================================================" Success "VSCodium (codium) installation complete!" Info "==================================================" Info "" Info "Getting started:" Info " codium . - Open current folder in VSCodium" Info " codium - Open file in VSCodium" Info " codium --install-extension - Install Open VSX extension" Info " codium --version - Show version info" Info "" Info "NOTE: Open a new terminal window if 'codium' command is not immediately recognized." } Main