Truffle compiler error: Requested contract not found

Hi everyone, I am trying to do some really simple compile and deploy with truffle but run into this error:

Error: The requested contract was not found. Make sure the source code is available for compilation
    at getContractNameAndRunValidation (D:\solidity\LilNifty-contracts\node_modules\@openzeppelin\upgrades-core\src\validate\query.ts:46:11)
    at Object.getStorageLayout (D:\solidity\LilNifty-contracts\node_modules\@openzeppelin\upgrades-core\src\validate\query.ts:54:41)        
    at Object.deployImpl (D:\solidity\LilNifty-contracts\node_modules\@openzeppelin\truffle-upgrades\src\utils\deploy-impl.ts:32:18)        
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at deployProxy (D:\solidity\LilNifty-contracts\node_modules\@openzeppelin\truffle-upgrades\src\deploy-proxy.ts:46:16)
    at module.exports (D:\solidity\LilNifty-contracts\migrations\2_Nifty_Proxy_deployment.js:6:3)
    at Migration._deploy (C:\Users\sound\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:80:1)        
    at Migration._load (C:\Users\sound\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:61:1)
    at Migration.run (C:\Users\sound\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:218:1)
    at Object.runMigrations (C:\Users\sound\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:150:1)        
    at Object.runFrom (C:\Users\sound\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:110:1)
    at Object.runAll (C:\Users\sound\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:114:1)
    at Object.run (C:\Users\sound\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:79:1)
    at runMigrations (C:\Users\sound\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:258:1)   
    at Object.run (C:\Users\sound\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:223:1)      
    at Command.run (C:\Users\sound\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\command.js:167:1)

Never had it before, but running into this since two days, Trying to setup an erc1155 upgradeable project.

:computer: Environment

Truffle v5.3.14
Node.js v16.3.0
@openzeppelin/contracts-upgradeable”: “^4.2.0”,
@openzeppelin/truffle-upgrades”: “^1.8.0”

package.json
{
  "dependencies": {
    "@openzeppelin/contracts-upgradeable": "^4.2.0",
    "@openzeppelin/truffle-upgrades": "^1.8.0"
  },
  "name": "lilnifty-contracts",
  "description": "",
  "version": "1.0.0",
  "main": "truffle-config.js",
  "directories": {
    "test": "test"
  },
  "devDependencies": {
    "mocha": "^8.1.2",
    "truffle": "^5.3.14"
  },
  "scripts": {
    "test": "mocha"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/LilNifty/LilNifty-contracts.git"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/LilNifty/LilNifty-contracts/issues"
  },
  "homepage": "https://github.com/LilNifty/LilNifty-contracts#readme"
}

Anyone have a clue how to fix this?

Also, I am getting this report from the compiler run:

✔ Fetching solc version list from solc-bin. Attempt #1
> Compiling @openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol
> Compiling @openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol
> Compiling @openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol
> Compiling @openzeppelin\contracts-upgradeable\proxy\utils\Initializable.sol
> Compiling @openzeppelin\contracts-upgradeable\token\ERC1155\IERC1155ReceiverUpgradeable.sol
> Compiling @openzeppelin\contracts-upgradeable\token\ERC1155\IERC1155Upgradeable.sol
> Compiling @openzeppelin\contracts-upgradeable\token\ERC1155\extensions\IERC1155MetadataURIUpgradeable.sol
> Compiling @openzeppelin\contracts-upgradeable\utils\AddressUpgradeable.sol
> Compiling @openzeppelin\contracts-upgradeable\utils\ContextUpgradeable.sol
> Compiling @openzeppelin\contracts-upgradeable\utils\StringsUpgradeable.sol
> Compiling @openzeppelin\contracts-upgradeable\utils\introspection\ERC165Upgradeable.sol
> Compiling @openzeppelin\contracts-upgradeable\utils\introspection\IERC165Upgradeable.sol
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\Nifty.sol
> Compiling .\contracts\NiftyAdmin.sol
> Compiling .\contracts\NiftyAdmin.sol
✔ Fetching solc version list from solc-bin. Attempt #1
> Artifacts written to D:\solidity\LilNifty-contracts\build\contracts
> Compiled successfully using:
   - solc: 0.8.6+commit.11564f7e.Emscripten.clang


> Duplicate contract names found for NiftyAdmin.
> This can cause errors and unknown behavior. Please rename one of your contracts.

Which is so strange that I am really puzzled. there is only one NiftAdmin.sol in the contracts folder, Why is it compiling it twice??

1 Like

So what does your contracts folder look like?

1 Like

nothing special, a truffle init folder structure

Same problem. Could someone help?

Same problem here. Anyone know?

I too, had this issue. For me, importing a local file caused the issue.

By removing import "./ExtraDataTypes.sol"; from my contract and declaring the types in the main contract file, the error went away.

I found the answer I was looking for here.
why-do-i-have-to-recompile-all-contracts-for-truffle

Exact problem as me. I get this error at the moment I import any sol file locally. If I stop inheriting anything locally, the deployProxy works.
Everything is using inheriting from upgradeable contracts except for when it is inheriting something local, but those are also inheriting upgradeable contracts.
I have tried deleing the abi jsons folder. I don't know where is the build folder.
When I use truffle compile --all && truffle migrate --reset I get "Artifacts are from different compiler runs"
I tried to declare all the contracts in the main contract folder but I get another error: "Cannot read property 'layout' of undefined".
Any help is appreciated! tia.

Truffle v5.4.1
Solidity v0.8.9
Node v16.5.0
Web3 v1.0.0
truffle-upgrades v^1.12.0
Windows 10