diff --git a/scripts/dev-override.ts b/scripts/dev-override.ts index 9a83daa..b8a7f41 100755 --- a/scripts/dev-override.ts +++ b/scripts/dev-override.ts @@ -1,5 +1,5 @@ #!/usr/bin/env bun -import { chmodSync, copyFileSync, existsSync, mkdirSync, realpathSync, renameSync, rmSync } from "node:fs"; +import { accessSync, chmodSync, constants, copyFileSync, existsSync, mkdirSync, realpathSync, renameSync, rmSync } from "node:fs"; import { spawnSync } from "node:child_process"; import { homedir } from "node:os"; import { dirname, join, resolve } from "node:path"; @@ -64,7 +64,19 @@ async function main() { const targetPath = resolveTargetBinaryPath(); const targetDir = dirname(targetPath); - mkdirSync(targetDir, { recursive: true }); + + try { + mkdirSync(targetDir, { recursive: true }); + accessSync(targetDir, constants.W_OK); + if (existsSync(targetPath)) { + accessSync(targetPath, constants.W_OK); + } + } catch { + console.error(`❌ [dev:override] Permission denied: Target path '${targetPath}' requires root privileges.`); + console.error(`👉 Next action: run with sudo: 'sudo bun run dev:override'`); + console.error(`💡 Tip: To develop without sudo, migrate to user directory first: 'seal-use update --user'`); + process.exit(1); + } console.error(`==> [dev:override] Installing to global path: ${targetPath}`);