Skip to content

Commit

Permalink
fix: check if mise is valid binary when on PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
hverlin committed Jan 16, 2025
1 parent a1382c0 commit b008a9c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/utils/miseBinLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function resolveMisePath(): Promise<string> {
return configuredPath;
}
logger.warn(
`Configured mise path ${configuredPath} is invalid. Trying to resolve another path...`,
`Configured mise path "${configuredPath}" is invalid. Trying to resolve another path...`,
);
}

Expand All @@ -25,15 +25,17 @@ export async function resolveMisePath(): Promise<string> {
const result = await safeExec("where.exe", ["mise"]);
logger.info(`where mise: ${result.stdout}`);
const firstEntry = result.stdout.split("\r\n")?.[0];
if (firstEntry) {
return firstEntry.trim();
const miseLocation = firstEntry?.trim();
if (miseLocation && (await isValidBinary(miseLocation))) {
return miseLocation;
}
}

const result = await safeExec("which", ["mise"]);
logger.info(`which mise: ${result.stdout}`);
if (result.stdout) {
return result.stdout.trim();
const miseLocation = result.stdout?.trim();
logger.info(`which mise: ${miseLocation}`);
if (miseLocation && (await isValidBinary(miseLocation))) {
return miseLocation;
}

// Check common installation locations
Expand Down

0 comments on commit b008a9c

Please sign in to comment.