Skip to content

Commit 496353a

Browse files
committed
fix: improve error handling for Bun installation path in CI environments
1 parent 492073f commit 496353a

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

use.cjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,14 @@ const resolvers = {
366366
const { stdout } = await execAsync('bun pm bin -g');
367367
binDir = stdout.trim();
368368
} catch (error) {
369-
throw new Error('Bun is not installed or not available in PATH.', { cause: error });
369+
// In CI or fresh environments, the global directory might not exist
370+
// Try to get the default Bun install path
371+
const home = process.env.HOME || process.env.USERPROFILE;
372+
if (home) {
373+
binDir = path.join(home, '.bun', 'bin');
374+
} else {
375+
throw new Error('Unable to determine Bun global directory.', { cause: error });
376+
}
370377
}
371378

372379
const bunInstallRoot = path.resolve(binDir, '..');

use.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,14 @@ export const resolvers = {
411411
const { stdout } = await execAsync('bun pm bin -g');
412412
binDir = stdout.trim();
413413
} catch (error) {
414-
throw new Error('Bun is not installed or not available in PATH.', { cause: error });
414+
// In CI or fresh environments, the global directory might not exist
415+
// Try to get the default Bun install path
416+
const home = process.env.HOME || process.env.USERPROFILE;
417+
if (home) {
418+
binDir = path.join(home, '.bun', 'bin');
419+
} else {
420+
throw new Error('Unable to determine Bun global directory.', { cause: error });
421+
}
415422
}
416423

417424
const bunInstallRoot = path.resolve(binDir, '..');

0 commit comments

Comments
 (0)