slither
slither copied to clipboard
crytic_compile.platform.exceptions.InvalidCompilation: Unknown file: @openzeppelin/contracts-upgradeable/introspection/ERC165Upgradeable.sol
$ slither .
'npx hardhat compile --force' running
Compiling 28 files with 0.7.6
Compilation finished successfully
Creating Typechain artifacts in directory /home/proj/packages/contracts/typechain for target ethers-v5
Successfully generated Typechain artifacts!
Traceback (most recent call last):
File "/home/proj/.local/lib/python3.9/site-packages/slither/__main__.py", line 723, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/home/proj/.local/lib/python3.9/site-packages/slither/__main__.py", line 71, in process_all
compilations = compile_all(target, **vars(args))
File "/home/proj/.local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 489, in compile_all
compilations.append(CryticCompile(target, **kwargs))
File "/home/proj/.local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 109, in __init__
self._compile(**kwargs)
File "/home/proj/.local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 417, in _compile
self._platform.compile(self, **kwargs)
File "/home/proj/.local/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 118, in compile
contract_filename = convert_filename(
File "/home/proj/.local/lib/python3.9/site-packages/crytic_compile/utils/naming.py", line 102, in convert_filename
raise InvalidCompilation(f"Unknown file: {filename}")
crytic_compile.platform.exceptions.InvalidCompilation: Unknown file: @openzeppelin/contracts-upgradeable/introspection/ERC165Upgradeable.sol
ERROR:root:None
ERROR:root:Error in .
ERROR:root:Traceback (most recent call last):
File "/home/proj/.local/lib/python3.9/site-packages/slither/__main__.py", line 723, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/home/proj/.local/lib/python3.9/site-packages/slither/__main__.py", line 71, in process_all
compilations = compile_all(target, **vars(args))
File "/home/proj/.local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 489, in compile_all
compilations.append(CryticCompile(target, **kwargs))
File "/home/proj/.local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 109, in __init__
self._compile(**kwargs)
File "/home/proj/.local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 417, in _compile
self._platform.compile(self, **kwargs)
File "/home/proj/.local/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 118, in compile
contract_filename = convert_filename(
File "/home/proj/.local/lib/python3.9/site-packages/crytic_compile/utils/naming.py", line 102, in convert_filename
raise InvalidCompilation(f"Unknown file: {filename}")
crytic_compile.platform.exceptions.InvalidCompilation: Unknown file: @openzeppelin/contracts-upgradeable/introspection/ERC165Upgradeable.sol
ERC165Upgradeable Isnt used anywhere in the projects solidity files, but ERC721Upgradeable is which looks like it imports ERC165Upgradeable
Ubuntu 21.04 Silther 0.8.0
"hardhat": "^2.1.1",
"@openzeppelin/contracts-upgradeable": "^3.4.1-solc-0.7-2",
solidity: {
version: '0.7.6',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
Did you ever resolve this?
Did you ever resolve this?
Hi @jacobrosenthal. Thank you for reporting this
Did you run npm install
? If so, can you share the codebase where this happens?
This error was thrown from here: https://github.com/crytic/crytic-compile/blob/master/crytic_compile/utils/naming.py#L109
Just make sure the @openzeppelin library is in one of these directory:
cwd.joinpath(Path("node_modules"), filename)
cwd.joinpath(Path("contracts"), filename)
working_dir.joinpath(filename)
they are for me but that doesn't seem to resolve the issue. I'm still getting a "File not found" error
This is especially sticky for monorepo projects where something like @openzeppelin/*
is not installed in the relative node_modules/
but in the root workspace. Yarn 2 removed nohoist as well, so I haven't really found a good solution to this yet.
A temporary workaround is to symlink the relevant packages into the relative/workspace's node_modules/
dir but that gets pretty annoying and is temporary.
ETA: A solution is adding the following to the package.json
for the contract package:
"installConfig": {
"hoistingLimits": "dependencies"
},