mirror of
https://github.com/debpalash/VoiceStudio.git
synced 2026-12-04 01:18:16 +00:00
fix(installer): keep PowerShell probes profile-free (#4099)
Skip PowerShell startup profiles and interactive prompts during all NSIS process probes. Keep existing process ownership checks, and shorten temporary source checkout paths to avoid MSVC linker path limits. Add executable profile and source-build regressions, update Windows installation guidance and the Nix dependency hash. All 38 required and supporting checks pass, including Windows/Linux/macOS installation and Nix builds; CodeRabbit and Greptile found no code defects.
This commit is contained in:
1 parent
01573663a3
commit
f7a3a83ef0
7 files changed
+118
-22
No files matched your search
@@ -0,0 +1 @@
|
||||
Windows installer process checks skip custom PowerShell profiles, and source installs use shorter build paths to avoid MSVC linker failures (#4099)
|
||||
@@ -69,6 +69,18 @@ cannot be closed when the app is stopped, run the installer from a different
|
||||
folder (for example Downloads) and retry; keep your existing runtime, model
|
||||
cache and data folders.
|
||||
|
||||
Installer process checks run PowerShell without user startup profiles or
|
||||
interactive prompts. This prevents a custom profile that waits for input or
|
||||
runs a long command from stopping the Windows installation wizard.
|
||||
|
||||
If the native Windows installer still stops progressing, record its exact
|
||||
filename and version, your Windows version and architecture, whether this is
|
||||
a fresh install or an update, and how long it has waited. Include the last
|
||||
installer detail line if available, and note whether Task Manager shows the
|
||||
installer or a PowerShell child using CPU or disk. This screen runs before the
|
||||
app's Python setup, so the app's download log cannot diagnose it. Keep the
|
||||
existing runtime, models, voices and projects while collecting this evidence.
|
||||
|
||||
Or, from a regular (non-admin) PowerShell, let the
|
||||
[install script](script.md) pick the right installer, verify it, and open the
|
||||
wizard:
|
||||
@@ -178,6 +190,9 @@ Use this for development or to run current `main`. The install script's
|
||||
`main` mode (`$env:VOICESTUDIO_INSTALL_MODE='main'; irm https://voicestudio.sh/install.ps1 | iex`)
|
||||
builds and installs a desktop package from `main` without a checkout; see
|
||||
[the install script guide](script.md).
|
||||
The script uses a short, temporary checkout name to keep native dependency
|
||||
paths within MSVC's path limit. If your `TEMP` directory has a long path,
|
||||
choose a shorter temporary directory before starting a source build.
|
||||
|
||||
Prerequisites:
|
||||
|
||||
|
||||
@@ -138,3 +138,29 @@ try {
|
||||
} finally {
|
||||
Remove-Item -LiteralPath $uninstallRoot -Recurse -Force
|
||||
}
|
||||
|
||||
# Exercise main's actual checkout path. MSVC rejected this exact dependency
|
||||
# path at 265 characters with the previous GUID-prefixed scratch directory.
|
||||
$script:cancel = $false
|
||||
function git {
|
||||
param([Parameter(ValueFromRemainingArguments)] [string[]]$Arguments)
|
||||
if ($Arguments[0] -eq 'clone') {
|
||||
$checkout = $Arguments[-1]
|
||||
$leaf = Split-Path (Split-Path $checkout -Parent) -Leaf
|
||||
$windowsCheckout = "C:\Users\runneradmin\AppData\Local\Temp\$leaf\source"
|
||||
$library = "$windowsCheckout\native\desktop-bridge\target\x86_64-pc-windows-msvc\release\build\rustls-platform-verifier\8fcc12423317bf98\out\librustls_platform_verifier-8fcc12423317bf98.rlib"
|
||||
if ($library.Length -ge 260) { throw "MSVC cannot link the installer's dependency path ($($library.Length) characters)." }
|
||||
New-Item -ItemType Directory -Path (Join-Path $checkout 'electron/release') -Force | Out-Null
|
||||
[IO.File]::WriteAllText((Join-Path $checkout 'package.json'), '{"version":"1.2.3"}')
|
||||
[IO.File]::WriteAllText((Join-Path $checkout 'electron/release/VoiceStudio-1.2.3-win-x64.exe'), 'fixture')
|
||||
}
|
||||
$global:LASTEXITCODE = 0
|
||||
}
|
||||
function node { $global:LASTEXITCODE = 0 }
|
||||
function bun { $global:LASTEXITCODE = 0 }
|
||||
function cargo { $global:LASTEXITCODE = 0 }
|
||||
function uv { $global:LASTEXITCODE = 0 }
|
||||
$script:launched = $false
|
||||
& $installer -Main -Silent
|
||||
if (-not $script:launched) { throw 'Main build did not launch setup' }
|
||||
Write-Output 'PASS: main build scratch directory stays within MSVC path limits'
|
||||
@@ -1,9 +1,10 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { spawn, spawnSync } from 'node:child_process';
|
||||
import { once } from 'node:events';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { dirname, join, resolve } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { test } from 'node:test';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
@@ -17,6 +18,60 @@ assert.match(template, /System::Call 'kernel32::SetEnvironmentVariableW\(w "ELEC
|
||||
'installer passes the unquoted path through its child environment');
|
||||
const powershell = process.platform === 'win32' ? 'powershell.exe' : 'pwsh';
|
||||
const available = spawnSync(powershell, ['-NoProfile', '-Command', 'exit 0']);
|
||||
const probes = [...template.matchAll(/nsExec::Exec `"\$PowerShellPath" (.+)`/g)]
|
||||
.map((match) => match[1]);
|
||||
|
||||
test('installer-owned PowerShell probes skip profiles and interactive prompts', () => {
|
||||
assert.equal(probes.length, 4);
|
||||
for (const probe of probes) {
|
||||
assert.match(probe, /-NoProfile\b/i);
|
||||
assert.match(probe, /-NonInteractive\b/i);
|
||||
}
|
||||
});
|
||||
|
||||
test('the NSIS availability probe does not load a user profile', {
|
||||
// PowerShell on macOS/Linux exposes an isolated profile through XDG_CONFIG_HOME.
|
||||
// Windows profile locations cannot be redirected without changing real user state.
|
||||
skip: process.platform === 'win32' || available.error?.code === 'ENOENT',
|
||||
timeout: 60_000,
|
||||
}, () => {
|
||||
const scratch = mkdtempSync(join(tmpdir(), 'voice-nsis-profile-'));
|
||||
const loaded = join(scratch, 'profile-loaded');
|
||||
const env = { ...process.env, XDG_CONFIG_HOME: scratch, VS_PROFILE_MARKER: loaded };
|
||||
try {
|
||||
const lookup = spawnSync(powershell, ['-NoProfile', '-NonInteractive', '-Command', '$PROFILE'], {
|
||||
encoding: 'utf8', env, timeout: 20_000,
|
||||
});
|
||||
assert.equal(lookup.status, 0, lookup.stderr);
|
||||
const profile = lookup.stdout.trim();
|
||||
assert.ok(profile.startsWith(scratch), 'only a scratch PowerShell profile may be written');
|
||||
mkdirSync(dirname(profile), { recursive: true });
|
||||
writeFileSync(profile, 'Set-Content -LiteralPath $env:VS_PROFILE_MARKER -Value loaded\n', 'utf8');
|
||||
|
||||
// Execute the availability command shipped in the actual NSIS template.
|
||||
const marker = probes[0].indexOf('-C "');
|
||||
assert.ok(marker >= 0);
|
||||
const switches = probes[0].slice(0, marker).trim().split(/\s+/).filter(Boolean);
|
||||
// CIM is Windows-only. Supply the command locally so Get-Command does not
|
||||
// search installed modules on macOS/Linux; the installed probe stays intact.
|
||||
const command = `function Get-CimInstance { }\n${probes[0].slice(marker + 4, -1)}`;
|
||||
const control = spawnSync(powershell, [...switches.filter((flag) => !/^-NoProfile$/i.test(flag)), '-Command', command], {
|
||||
encoding: 'utf8', env, timeout: 20_000,
|
||||
});
|
||||
assert.ifError(control.error);
|
||||
assert.equal(control.status, 0, control.stderr);
|
||||
assert.ok(existsSync(loaded), 'negative control must load the isolated profile');
|
||||
rmSync(loaded);
|
||||
const result = spawnSync(powershell, [...switches, '-Command', command], {
|
||||
encoding: 'utf8', env, timeout: 20_000,
|
||||
});
|
||||
assert.ifError(result.error);
|
||||
assert.equal(result.status, 0, result.stderr);
|
||||
assert.equal(existsSync(loaded), false, 'installer probe must skip the isolated profile');
|
||||
} finally {
|
||||
rmSync(scratch, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
for (const root of ['E:\\NN\\VoiceStudio', 'E:\\NN\\VoiceStudio\\', "E:\\O'Brien\\VoiceStudio", 'E:\\']) {
|
||||
test(`installer only matches processes inside ${root}`, {
|
||||
|
||||
@@ -342,7 +342,7 @@
|
||||
pkgs.nodejs_22
|
||||
];
|
||||
outputHashMode = "recursive";
|
||||
outputHash = "sha256-rm7NuMY+mQQwdMfzlB7vC+ojyVdLl4tYqLXt2X0sUiI=";
|
||||
outputHash = "sha256-bqxnoXhbM2HK+xW+pBOy71WjSuAhsbjbr429b+uT6WU=";
|
||||
sourceProvenance = null;
|
||||
} ''
|
||||
export HOME=$TMPDIR
|
||||
|
||||
@@ -1,31 +1,28 @@
|
||||
diff --git a/templates/nsis/include/allowOnlyOneInstallerInstance.nsh b/templates/nsis/include/allowOnlyOneInstallerInstance.nsh
|
||||
index a5cb3fe536a9fe95a95ac796f92a27f62d9762cc..476ee3c435425c1c186f34dba18036474aaa1e8b 100644
|
||||
--- a/templates/nsis/include/allowOnlyOneInstallerInstance.nsh
|
||||
+++ b/templates/nsis/include/allowOnlyOneInstallerInstance.nsh
|
||||
@@ -34,6 +34,8 @@
|
||||
Var /GLOBAL PowerShellPath
|
||||
StrCpy $CmdPath "$SYSDIR\cmd.exe"
|
||||
@@ -36,2 +36,4 @@
|
||||
StrCpy $PowerShellPath "$SYSDIR\WindowsPowerShell\v1.0\powershell.exe"
|
||||
+ # Keep the path out of PowerShell source (install folders may contain quotes).
|
||||
+ System::Call 'kernel32::SetEnvironmentVariableW(w "ELECTRON_BUILDER_INSTALL_ROOT", w "$INSTDIR")i.r0'
|
||||
!ifmacrodef customCheckAppRunning
|
||||
!insertmacro customCheckAppRunning
|
||||
!else
|
||||
@@ -63,7 +65,7 @@
|
||||
|
||||
!macro FIND_PROCESS _FILE _RETURN
|
||||
@@ -47,3 +49,3 @@
|
||||
# Try running PowerShell with a simple command to check if it's available
|
||||
- nsExec::Exec `"$PowerShellPath" -C "if (Get-Command Get-CimInstance -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"`
|
||||
+ nsExec::Exec `"$PowerShellPath" -NoProfile -NonInteractive -C "if (Get-Command Get-CimInstance -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }"`
|
||||
Pop $0 # Return code (0 = success, other = error)
|
||||
@@ -52,3 +54,3 @@
|
||||
# PowerShell is available, check if it's not blocked by policies
|
||||
- nsExec::Exec `"$PowerShellPath" -C "if ((Get-ExecutionPolicy -Scope Process) -eq 'Restricted') { exit 1 } else { exit 0 }"`
|
||||
+ nsExec::Exec `"$PowerShellPath" -NoProfile -NonInteractive -C "if ((Get-ExecutionPolicy -Scope Process) -eq 'Restricted') { exit 1 } else { exit 0 }"`
|
||||
Pop $0
|
||||
@@ -65,3 +67,3 @@
|
||||
${if} $IsPowerShellAvailable == 0
|
||||
- nsExec::Exec `"$PowerShellPath" -C "if ((Get-CimInstance -ClassName Win32_Process | ? {$$_.Path -and $$_.Path.StartsWith('$INSTDIR', 'CurrentCultureIgnoreCase')}).Count -gt 0) { exit 0 } else { exit 1 }"`
|
||||
+ nsExec::Exec `"$PowerShellPath" -C "if ((Get-CimInstance -ClassName Win32_Process | ? {$$_.ExecutablePath -and $$_.ProcessId -ne $pid -and $$_.ExecutablePath.StartsWith(($$env:ELECTRON_BUILDER_INSTALL_ROOT.TrimEnd([char]92) + [char]92), 'OrdinalIgnoreCase')}).Count -gt 0) { exit 0 } else { exit 1 }"`
|
||||
+ nsExec::Exec `"$PowerShellPath" -NoProfile -NonInteractive -C "if ((Get-CimInstance -ClassName Win32_Process | ? {$$_.ExecutablePath -and $$_.ProcessId -ne $pid -and $$_.ExecutablePath.StartsWith(($$env:ELECTRON_BUILDER_INSTALL_ROOT.TrimEnd([char]92) + [char]92), 'OrdinalIgnoreCase')}).Count -gt 0) { exit 0 } else { exit 1 }"`
|
||||
Pop ${_RETURN}
|
||||
${else}
|
||||
!ifdef INSTALL_MODE_PER_ALL_USERS
|
||||
@@ -91,7 +93,7 @@
|
||||
${endIf}
|
||||
|
||||
@@ -93,3 +95,3 @@
|
||||
${if} $IsPowerShellAvailable == 0
|
||||
- nsExec::Exec `"$PowerShellPath" -C "Get-CimInstance -ClassName Win32_Process | ? {$$_.Path -and $$_.Path.StartsWith('$INSTDIR', 'CurrentCultureIgnoreCase')} | % { Stop-Process -Id $$_.ProcessId $0 }"`
|
||||
+ nsExec::Exec `"$PowerShellPath" -C "Get-CimInstance -ClassName Win32_Process | ? {$$_.ExecutablePath -and $$_.ProcessId -ne $pid -and $$_.ExecutablePath.StartsWith(($$env:ELECTRON_BUILDER_INSTALL_ROOT.TrimEnd([char]92) + [char]92), 'OrdinalIgnoreCase')} | % { Stop-Process -Id $$_.ProcessId $0 }"`
|
||||
+ nsExec::Exec `"$PowerShellPath" -NoProfile -NonInteractive -C "Get-CimInstance -ClassName Win32_Process | ? {$$_.ExecutablePath -and $$_.ProcessId -ne $pid -and $$_.ExecutablePath.StartsWith(($$env:ELECTRON_BUILDER_INSTALL_ROOT.TrimEnd([char]92) + [char]92), 'OrdinalIgnoreCase')} | % { Stop-Process -Id $$_.ProcessId $0 }"`
|
||||
${else}
|
||||
!ifdef INSTALL_MODE_PER_ALL_USERS
|
||||
nsExec::Exec `taskkill /IM "${_FILE}" /FI "PID ne $pid"`
|
||||
+3
-1
@@ -57,7 +57,9 @@ function Run-Checked([string]$Command, [string[]]$Arguments) {
|
||||
}
|
||||
if ($vsVersion) { $vsVersion = $vsVersion -replace '^v', ''; Assert-Version $vsVersion }
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
$work = Join-Path ([IO.Path]::GetTempPath()) ('voicestudio-install-' + [Guid]::NewGuid())
|
||||
# MSVC still encounters MAX_PATH in nested Cargo dependency outputs. Keep this
|
||||
# unique checkout root short so main builds fit below the limit on normal TEMP.
|
||||
$work = Join-Path ([IO.Path]::GetTempPath()) ('vs-install-' + [IO.Path]::GetRandomFileName())
|
||||
New-Item -ItemType Directory -Path $work | Out-Null
|
||||
try {
|
||||
if ($mode -eq 'main') {
|
||||
|
||||
Reference in new issue
Block a user