Skip to content

Commit

Permalink
Merge pull request #3284 from NomicFoundation/hardhat-211-fails-in-do…
Browse files Browse the repository at this point in the history
…cker-environments-hh-1188

Fix how native solc is checked after download
  • Loading branch information
fvictorio committed Oct 27, 2022
2 parents 3f162e2 + 145b12c commit 09d164e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
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;
}
}
}

0 comments on commit 09d164e

Please sign in to comment.