From 93f05eb3f82c3128d876148547c595a04c7d4be4 Mon Sep 17 00:00:00 2001 From: Test User Date: Thu, 6 Nov 2025 08:59:42 -0500 Subject: [PATCH 1/2] fix(dlx): use spawnNode instead of spawn('node') for SEA compatibility Replace direct spawn('node') calls with spawnNode() utility to properly handle SEA binary execution. spawnNode() automatically: - Uses system Node.js when available in SEA context - Falls back to SEA self-spawning with IPC handshake - Uses process.execPath in non-SEA context This ensures local Coana and cdxgen binaries work correctly whether running from SEA binary or standard Node.js installation. Changes: - Import spawnNode from ../spawn/spawn-node.mts - Replace spawn('node', ...) with spawnNode(...) in spawnCoanaDlx - Replace spawn('node', ...) with spawnNode(...) in spawnCdxgenDlx - Remove unused spawn import from @socketsecurity/lib/spawn --- packages/cli/src/utils/dlx/spawn.mts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/utils/dlx/spawn.mts b/packages/cli/src/utils/dlx/spawn.mts index b66a7638d..b8b5ae65c 100644 --- a/packages/cli/src/utils/dlx/spawn.mts +++ b/packages/cli/src/utils/dlx/spawn.mts @@ -16,9 +16,9 @@ import { SOCKET_PUBLIC_API_TOKEN } from '@socketsecurity/lib/constants/socket' import { dlxPackage } from '@socketsecurity/lib/dlx-package' -import { spawn } from '@socketsecurity/lib/spawn' import { resolveCdxgen, resolveCoana } from './resolve-binary.mjs' +import { spawnNode } from '../spawn/spawn-node.mts' import { getDefaultOrgSlug } from '../../commands/ci/fetch-default-org-slug.mjs' import ENV from '../../constants/env.mts' import { @@ -133,7 +133,7 @@ export async function spawnCoanaDlx( ...mixinsEnv, ...spawnEnv, } - const spawnResult = await spawn('node', [resolution.path, ...args], { + const spawnResult = await spawnNode([resolution.path, ...args], { cwd: dlxOptions.cwd, env: finalEnv, stdio: spawnExtra?.['stdio'] || 'inherit', @@ -202,7 +202,7 @@ export async function spawnCdxgenDlx( ...options, } as DlxOptions - const spawnResult = spawn('node', [resolution.path, ...args], { + const spawnResult = spawnNode([resolution.path, ...args], { cwd: dlxOptions.cwd, env: { ...process.env, From db6e31128208f0a0d125b139e305895353663296 Mon Sep 17 00:00:00 2001 From: Test User Date: Thu, 6 Nov 2025 09:01:43 -0500 Subject: [PATCH 2/2] fix(cli): use spawnNode for local pip and python CLI execution Replace spawn('node') with spawnNode() for SEA compatibility when executing local sfw and python-cli binaries. This ensures proper Node.js resolution in SEA contexts. Changes: - cmd-pip.mts: Use spawnNode for local sfw execution - python/standalone.mts: Use spawnNode for local python-cli execution --- packages/cli/src/commands/pip/cmd-pip.mts | 3 ++- packages/cli/src/utils/python/standalone.mts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/commands/pip/cmd-pip.mts b/packages/cli/src/commands/pip/cmd-pip.mts index c08072a3c..4ad111c92 100644 --- a/packages/cli/src/commands/pip/cmd-pip.mts +++ b/packages/cli/src/commands/pip/cmd-pip.mts @@ -28,6 +28,7 @@ import { WIN32 } from '@socketsecurity/lib-internal/constants/platform' import { spawn } from '@socketsecurity/lib-internal/spawn' import { commonFlags } from '../../flags.mts' +import { spawnNode } from '../../utils/spawn/spawn-node.mts' import { meowOrExit } from '../../utils/cli/with-subcommands.mjs' import { resolveSfw } from '../../utils/dlx/resolve-binary.mjs' import { filterFlags } from '../../utils/process/cmd.mts' @@ -108,7 +109,7 @@ async function run( // Use local sfw if available, otherwise use pnpm dlx. const result = resolution.type === 'local' - ? await spawn('node', [resolution.path, 'pip', ...argsToForward], { + ? await spawnNode([resolution.path, 'pip', ...argsToForward], { shell: WIN32, stdio: 'inherit', }) diff --git a/packages/cli/src/utils/python/standalone.mts b/packages/cli/src/utils/python/standalone.mts index 355fbfe42..927ce381e 100644 --- a/packages/cli/src/utils/python/standalone.mts +++ b/packages/cli/src/utils/python/standalone.mts @@ -56,6 +56,7 @@ import ENV from '../../constants/env.mts' import { PYTHON_MIN_VERSION } from '../../constants/packages.mts' import { resolvePyCli } from '../dlx/resolve-binary.mjs' import { getErrorCause, InputError } from '../error/errors.mts' +import { spawnNode } from '../spawn/spawn-node.mts' import type { CResult } from '../../types.mjs' @@ -388,7 +389,7 @@ export async function spawnSocketPython( // Use local Python CLI if available. if (resolution.type === 'local') { - const spawnResult = await spawn('node', [resolution.path, ...args], { + const spawnResult = await spawnNode([resolution.path, ...args], { cwd: options?.cwd, env: finalEnv, shell: WIN32,