Skip to content

Commit

Permalink
Recommend installing xz if it's missing (#619)
Browse files Browse the repository at this point in the history
* Recommend installing `xz` if it's missing

* Create spicy-years-mate.md
  • Loading branch information
Andarist authored Jul 10, 2024
1 parent 683cb81 commit 93e8732
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-years-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"replayio": patch
---

Recommend installing `xz` if it's missing and the browser can't be extracted because of that
18 changes: 13 additions & 5 deletions packages/replayio/src/utils/installation/installLatestRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ export const installLatestRelease = createAsyncFunctionWithTracking(
};
} catch (error) {
logger.error("InstallLatestRelease:Failed", { error });
progress.setFailed(
"Something went wrong installing the Replay browser. Please try again later."
);

progress.setFailed("Something went wrong installing the Replay browser.");
throw error;
}
},
Expand Down Expand Up @@ -150,18 +149,27 @@ async function downloadReplayFile({ onRetry }: { onRetry?: (attempt: number) =>
throw new Error("Download failed, giving up");
}

async function extractBrowserArchive(runtimeBaseDir: string, downloadFilePath: string) {
function extractBrowserArchive(runtimeBaseDir: string, downloadFilePath: string) {
logger.info(`ExtractBrowserArchive:Extracting`, { downloadFilePath });

const tarResult = spawnSync("tar", ["xf", runtimeMetadata.downloadFileName], {
cwd: runtimeBaseDir,
});
if (tarResult.status !== 0) {
const hasXz = spawnSync("which", ["xz"]).status === 0;

logger.error("ExtractBrowserArchive:Failed", {
downloadFilePath,
hasXz,
stderr: String(tarResult.stderr),
});

throw new Error("Unable to extract browser archive");
let message = "Unable to extract browser archive";

if (!hasXz) {
message += `. xz is required to decompress it. Please install xz and try again.`;
}

throw new Error(message);
}
}

0 comments on commit 93e8732

Please sign in to comment.