-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Version of Hardhat
3.0.0-next.29
What happened?
npx hardhat compile
fails with a nondescriptive error message if /tmp/hardhat-solc
is not writable.
The spawnCompile()
function creates the folder, resulting it being owned by the current user.
If another user attempts compilation while the folder exists, it throws an error.
hardhat/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.ts
Lines 50 to 58 in 58a9598
async function spawnCompile( | |
command: string, | |
args: string[], | |
input: CompilerInput, | |
): Promise<CompilerOutput> { | |
// We create a temporary folder to store the output of the compiler in | |
// We use a random UUID to avoid collisions with other compilations | |
const tmpFolder = path.join(os.tmpdir(), "hardhat-solc", crypto.randomUUID()); | |
await mkdir(tmpFolder); |
mkdir()
by default does create folders with mode 777
, but since the default umask is 022
, it results in a folder with 755
(nodejs/node#15092)
This can be fixed by explicitly using chmod()
to set the permission after creation.
Minimal reproduction steps
On a system that has more than one user:
- compile project as user a
sudo su user-a npx hardhat compile
- switch to user b
sudo su user-b
- attempt to compile project as user b
$ npx hardhat compile Compiling your Solidity contracts... Error HHE907: A native version of solc failed to run. If you are running MacOS, try installing Apple Rosetta. If this error persists, run "npx hardhat clean --global".
Search terms
compile error, /tmp/hardhat-solc not writable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status