Skip to content

Commit 71caa25

Browse files
committed
fix(bootstrap): improve error handling for CLI download failures
Adds better error handling and helpful recovery instructions when dlxPackage fails to download @socketsecurity/cli. - Add explicit error handling for DLX directory creation - Provide helpful troubleshooting steps on download failure - Include link to GitHub issues for bug reports Addresses directory creation issues in dlxPackage that can occur in some environments.
1 parent 7541ecd commit 71caa25

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

packages/bootstrap/src/shared/bootstrap-shared.mjs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,15 @@ export async function downloadCli() {
119119
logger.log('📦 Socket CLI not found, downloading...')
120120
logger.log('')
121121

122-
// Create directories.
123-
mkdirSync(SOCKET_DLX_DIR, { recursive: true })
122+
// Create DLX directory with recursive option to ensure all parents exist.
123+
try {
124+
mkdirSync(SOCKET_DLX_DIR, { recursive: true })
125+
} catch (e) {
126+
logger.error('Failed to create Socket directory')
127+
logger.error(` Error: ${e instanceof Error ? e.message : String(e)}`)
128+
logger.error(` Path: ${SOCKET_DLX_DIR}`)
129+
process.exit(1)
130+
}
124131

125132
try {
126133
// Use dlxPackage to download and install @socketsecurity/cli.
@@ -152,6 +159,12 @@ export async function downloadCli() {
152159
} catch (e) {
153160
logger.error('Failed to download Socket CLI')
154161
logger.error(` Error: ${e instanceof Error ? e.message : String(e)}`)
162+
logger.error('')
163+
logger.error('This may be a temporary issue. Please try:')
164+
logger.error(' 1. Check your internet connection')
165+
logger.error(' 2. Try running the command again')
166+
logger.error(` 3. Manually create directory: mkdir -p "${SOCKET_DLX_DIR}"`)
167+
logger.error(' 4. Report issue at: https://github.com/SocketDev/socket-cli/issues')
155168
process.exit(1)
156169
}
157170
}

0 commit comments

Comments
 (0)