truffle
truffle copied to clipboard
InternalCompilerError: Compiled contract not found.
Issue
After having deployed my contracts, and with artefacts in the /build
folder, I cannot re-run truffle compile
.
Calling truffle compile
gives me:
InternalCompilerError: Compiled contract not found.
I could rm -rf ./build
, but this would remove artefacts with deployment addresses I want to keep.
Environment
- Operating System: Archlinux
- Ethereum client: None involved here
- Truffle version (
truffle version
): 5.1.22 - node version (
node --version
): v10.16.3 - npm version (
npm --version
): 6.14.4
Sounds like there's two problems here:
- InternalCompilerError's shouldn't happen, so that's something going wrong with Solidity. If we can get to the bottom of it, hopefully we'll be able to isolate the problem to bring up with them.
- Something inside Truffle must be triggering this issue. Is your repo online? And can you share the artifacts in the current state? Maybe we can figure out what's going wrong.
Thanks @Amxx!
To reproduce:
git clone [email protected]:Amxx/NFWallet.git
cd NFWallet
npm i
npm run build # works
touch contracts/NFWallet.sol
npm run build # error
I have the same issue,how to fix this?
@gnidan I have the same issue
I have a reliable repro for this in https://github.com/ethereum/solidity/issues/7627#issuecomment-705613016
This is an issue in the compiler that happens in pretty specific circumstances (when recompiling several contracts but requesting output only for some of them and when some specific language features are used).
It's going to be fixed in Solidity but for the time being a workaround is just to force Truffle to recompile everything (e.g. by removing the build/
directory).
I could rm -rf ./build, but this would remove artefacts with deployment addresses I want to keep.
Another way to force a recompile would be to run touch
on all contracts to update their modification date. Or not necessarily on all of them - just the ones that are triggering this issue, though it might be hard to track down which ones those are.
You can also do truffle compile --all
or truffle test --compile-all
Just to let you know: this bug is now fixed Solidity 0.7.4.
EDIT: I managed to fix my problem - that said, i did hit InternalCompilerError: Compiled contract not found.
with npx hardhat compile
, by having a contract try to get its own .creationCode
. I suppose this comment is on the wrong issue, since this is apparently for truffle, but I don't recall seeing another issue open for this error message, so I commented here.
Orig text:
I'm getting InternalCompilerError: Compiled contract not found.
with npx hardhat compile
Seems like there are still some issues.
Since a repro was mentioned above, don't want to cut a minimal repro right now.
This issue has persisted even after i deleted artifacts
and cache
and even after I changed the part of the code that I thought may have been causing the issue.
EDIT:
I've boiled this down to the issue - I want to use create2
to put my contract at a specific address, and then i want other contracts to know the address I've deployed to. So I have:
Contract A {
address public constant myAddr =
address(uint160(uint(keccak256(abi.encodePacked(
bytes1(0xff),
/* Addr to deploy with */,
uint256(/* Salt */),
keccak256(abi.encodePacked(type(A).creationCode))
)))));
... }
But naturally .creationCode
can't really work since it hasn't been compiled yet.
EDIT: I realized the way to fix this is to move myAddr
out of the contract but into the same file as the contract.