-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Describe the issue
When a file can't be compiled because no solc version in the config is compatible with its version pragma and those of its dependencies, you get an error like this:
Error HHE909: Failed to create compilation job for file "<file>" using the build profile "default".
No solc version enabled in this profile is compatible with this file and all of its dependencies.
This is fine when <file> has the problematic pragma, but it's not as helpful if the problem is in one of its dependencies. The error would be much better if it included more information about what exactly is going on, because it can happen that <file> has a big dependency tree and the incompatible pragma is in some random file down that tree.
Reproduction steps
These reproduction steps are contrived, but the idea is to have a file that depends on another file, and where only the dependent can't be compiled. This illustrates that the source of the problem (the pragma of the dependency) cannot be inferred from the error.
// IFoo.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.28;
interface IFoo {}// Foo.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;
import { IFoo } from "./IFoo.sol";
contract Foo is IFoo {}// hardhat.config.ts
import hardhatToolboxViemPlugin from "@nomicfoundation/hardhat-toolbox-viem";
import { configVariable, defineConfig } from "hardhat/config";
export default defineConfig({
plugins: [hardhatToolboxViemPlugin],
solidity: {
compilers: [
{
version: "0.8.28",
},
{
version: "0.8.29",
},
],
overrides: {
"contracts/Foo.sol": {
version: "0.8.29",
},
},
},
});Other comments
Some things worth noting:
- Since this is an error condition, performance doesn't matter that much. We can do whatever we need to build the best possible error.
- We should avoid printing a huge error if there are a lot of incompatible files in the dependency tree. We could show only the first clearly incompatible file, or just the first N and mention that there are M more. We could also always print the whole list in the debug output, so that it's available if someone needs it.
Priority
I'm marking this as P1, because this happened to me during a migration. Since our compilation pipeline was significantly rewritten, errors related to it are likely, and they should be as helpful as possible.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status