Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crytic_compile.platform.exceptions.InvalidCompilation: Unknown file: @openzeppelin/contracts-upgradeable/introspection/ERC165Upgradeable.sol #852

Closed
jacobrosenthal opened this issue May 17, 2021 · 6 comments

Comments

@jacobrosenthal
Copy link

$ 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,
      },
    },
  },
@0xfoobar
Copy link

Did you ever resolve this?

1 similar comment
@luuuuo
Copy link

luuuuo commented Aug 12, 2021

Did you ever resolve this?

@montyly
Copy link
Member

montyly commented Aug 12, 2021

Hi @jacobrosenthal. Thank you for reporting this

Did you run npm install? If so, can you share the codebase where this happens?

@sc0Vu
Copy link

sc0Vu commented Oct 9, 2021

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)

@Philogy
Copy link

Philogy commented Jan 24, 2022

they are for me but that doesn't seem to resolve the issue. I'm still getting a "File not found" error

@mikeshultz
Copy link

mikeshultz commented Apr 28, 2022

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"
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants