Skip to content
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

Fix how native solc is checked after download #3284

Merged
merged 2 commits into from Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tall-llamas-remember.md
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Fixed a problem that was preventing Hardhat from being used in Alpine Linux.
22 changes: 11 additions & 11 deletions packages/hardhat-core/src/internal/solidity/compiler/downloader.ts
Expand Up @@ -3,6 +3,8 @@ import fsExtra from "fs-extra";
import debug from "debug";
import os from "os";
import { execFile } from "child_process";
import { promisify } from "util";

import { download } from "../../util/download";
import { assertHardhatInvariant, HardhatError } from "../../core/errors";
import { ERRORS } from "../../core/errors-list";
Expand Down Expand Up @@ -345,17 +347,15 @@ export class CompilerDownloader implements ICompilerDownloader {
await fsExtra.createFile(this._getCompilerDoesntWorkFile(build));
}

private _checkNativeSolc(build: CompilerBuild) {
private async _checkNativeSolc(build: CompilerBuild) {
const solcPath = this._getCompilerBinaryPathFromBuild(build);
return new Promise((resolve) => {
try {
const process = execFile(solcPath, ["--version"]);
process.on("exit", (code) => {
resolve(code === 0);
});
} catch {
resolve(false);
}
});
const execFileP = promisify(execFile);

try {
await execFileP(solcPath, ["--version"]);
return true;
} catch {
return false;
}
}
}