Skip to content

Conversation

KartikSoneji
Copy link

  • Because this PR includes a bug fix, relevant tests have been included.

Fixes: #7161

Use chmod() to set permissions to 777 on the /tmp/hardhat-solc folder, if possible, to ensure it's accessible.

@github-project-automation github-project-automation bot moved this to Backlog in Hardhat Aug 8, 2025
@kanej kanej changed the base branch from v-next to main August 11, 2025 21:10
@alcuadrado
Copy link
Member

Hey, thanks for this PR. I'll take a look soon.

Another alternative would be to stop using tmp dirs and use <project>/cache/tmp or something like that. So that we avoid these kind of problems altogether. WDYT?

@KartikSoneji
Copy link
Author

Hmm the issue is it would force everyone to update their .gitignore files.

@alcuadrado
Copy link
Member

but everyone has cache/ in their gitignore files, we add it during initialization, and hardhat would be really annoying without it

@KartikSoneji
Copy link
Author

Oh ok.
Then that might be a better solution.
Should I make the changes?

@alcuadrado
Copy link
Member

if you want, that'd be cool.

I think in our own tests it's still fin to use tmp dirs. But in the actual code we should probably have a helper that creates them inside the cache dir. We have this:

export async function mkdtemp(prefix: string): Promise<string>;

Maybe it could be

export async function mkdtemp(cointainer: string, nameHint: string): Promise<string> 

so that we call it with hre.config.paths.cache as container, and it creates a new folder base on the nameHint.

@KartikSoneji
Copy link
Author

Should it be tmpDir instead?

So instead of:

export async function mkdtemp(prefix: string): Promise<string> {
  try {
    return await getRealPath(
      await fsPromises.mkdtemp(path.join(tmpdir(), prefix)),
    );
  } catch (e) {
    ensureNodeErrnoExceptionError(e);
    throw new FileSystemAccessError(e.message, e);
  }
}

It can be:

export async function mkdtemp(
  prefix: string,
  tmpDir: string = tmpdir(),
): Promise<string> {
  try {
    return await getRealPath(
      await fsPromises.mkdtemp(path.join(tmpDir, prefix)),
    );
  } catch (e) {
    ensureNodeErrnoExceptionError(e);
    throw new FileSystemAccessError(e.message, e);
  }
}

@KartikSoneji KartikSoneji changed the title fix: /tmp/hardhat/-solc permissions to be world writable fix: /tmp/hardhat-solc permissions to be world writable Aug 15, 2025
@kanej
Copy link
Member

kanej commented Aug 21, 2025

Hey @KartikSoneji, thanks for all the help here.
I am closing this PR as we tackled #7161 with this PR: #7220

@kanej kanej closed this Aug 21, 2025
@github-project-automation github-project-automation bot moved this from Backlog to Done in Hardhat Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

hh compile fails without detailed error message if /tmp/hardhat-solc is not writable
3 participants