Skip to content

Split any YouTube song into stems

TypeScript

fix(windows): make first-run setup work on Windows

Joef99ce4861f1f
diff --git a/scripts/run.cjs b/scripts/run.cjs
index c415839..b49d107 100644
--- a/scripts/run.cjs
+++ b/scripts/run.cjs
@@ -104,9 +104,10 @@ function resolveBin(name) {
function runSteps(steps) {
for (const [bin, ...args] of steps) {
const resolved = resolveBin(bin)
- const r = spawnSync(resolved, args, {
+ const useShell = IS_WIN && resolved.toLowerCase().endsWith('.cmd')
+ const r = spawnSync(useShell ? `"${resolved}"` : resolved, args, {
stdio: 'inherit',
- shell: IS_WIN && resolved.toLowerCase().endsWith('.cmd')
+ shell: useShell
})
if (r.status !== 0) process.exit(r.status ?? 1)
}
diff --git a/src/main/env.ts b/src/main/env.ts
index 30429b0..68f5b50 100644
--- a/src/main/env.ts
+++ b/src/main/env.ts
@@ -77,10 +77,6 @@ function runtimeDownloadUrl(): string {
)
}
-function venvPip(): string {
- return join(venvDir(), VENV_BIN, 'pip' + EXE)
-}
-
export function bundledFfmpeg(): string | null {
const name = 'ffmpeg' + EXE
const candidates = app.isPackaged
@@ -348,7 +344,11 @@ function downloadTo(url: string, dest: string, label: string): Promise<void> {
function extractArchive(archive: string, dest: string): Promise<void> {
return new Promise((resolve, reject) => {
mkdirSync(dest, { recursive: true })
- const child = spawn('tar', ['-xzf', archive, '-C', dest], { stdio: 'ignore' })
+ // GNU tar (e.g. Git for Windows) treats "C:\..." as a remote host and dies
+ // with "Cannot connect to C: resolve failed". Prefer Windows built-in bsdtar.
+ const sys32Tar = join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'tar.exe')
+ const tarBin = IS_WIN && existsSync(sys32Tar) ? sys32Tar : 'tar'
+ const child = spawn(tarBin, ['-xzf', archive, '-C', dest], { stdio: 'ignore' })
child.on('close', (code) =>
code === 0 ? resolve() : reject(new Error(`extract failed (${code})`))
)
@@ -401,7 +401,7 @@ export async function bootstrap(): Promise<boolean> {
try {
const venv = venvDir()
- const pip = venvPip()
+ const pip = venvPython()
sendEnvEvent('Preparing workspace')
await new Promise<void>((resolve, reject) => {
@@ -413,7 +413,7 @@ export async function bootstrap(): Promise<boolean> {
})
await new Promise<void>((resolve, reject) => {
- const child = spawn(pip, ['install', '-q', '-U', 'pip', 'wheel', 'setuptools'])
+ const child = spawn(pip, ['-m', 'pip', 'install', '-q', '-U', 'pip', 'wheel', 'setuptools'])
child.on('close', (code) =>
code === 0 ? resolve() : reject(new Error(`pip upgrade failed (${code})`))
)
@@ -424,6 +424,8 @@ export async function bootstrap(): Promise<boolean> {
let lastGeneric = 0
await new Promise<void>((resolve, reject) => {
const child = spawn(pip, [
+ '-m',
+ 'pip',
'install',
'--progress-bar',
'off',
@@ -463,7 +465,7 @@ export async function bootstrap(): Promise<boolean> {
})
await new Promise<void>((resolve, reject) => {
- const child = spawn(pip, ['install', '-q', 'yt-dlp-ejs'])
+ const child = spawn(pip, ['-m', 'pip', 'install', '-q', 'yt-dlp-ejs'])
child.on('close', (code) =>
code === 0 ? resolve() : reject(new Error(`solver install failed (${code})`))
)
@@ -488,7 +490,9 @@ export async function updateYtDlp(): Promise<boolean> {
try {
sendEnvEvent('Updating yt-dlp...')
await new Promise<void>((resolve, reject) => {
- const child = spawn(venvPip(), [
+ const child = spawn(venvPython(), [
+ '-m',
+ 'pip',
'install',
'-q',
'-U',