Skip to content

Throw a better error when trying to install with musl-libc #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion tool/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ export async function getDartSassEmbedded(
}
): Promise<void> {
const repo = 'dart-sass-embedded';

options ??= defaultVersionOption('compiler-version');

await checkForMusl();

if ('version' in options) {
const version = options?.version;
await downloadRelease({
Expand Down Expand Up @@ -155,6 +157,21 @@ export async function getDartSassEmbedded(
await link(p.join(source, 'build'), p.join(outPath, repo));
}

/**
* Throws an informative error if we're running in a Linux environment that uses
* musl.
*/
async function checkForMusl(): Promise<void> {
if (process.platform !== 'linux') return;

const executable = await fs.readFile(process.execPath);
if (!executable.includes('libc.musl-')) return;

throw Error(
"sass-embedded doesn't support Linux distributions that use musl-libc."
);
}

/**
* Checks out JS API type defintions from the Sass language repo.
*
Expand Down