[Bug-Candidate]: File not found. Searched the following locations: ""
Describe the issue:
When I try to run slither on cmd prompt I have this issue
This is the remappings.txt file:
ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
this is the foundry.toml file:
[profile.default]
solc_version = '0.8.16'
fuzz_runs = 500
libs = ['lib']
optimizer = true
optimizer_runs = 500000
out = 'dist/artifacts'
src = 'src'
test = 'test'
fs_permissions = [{ access = "read-write", path = "./"}]
[fmt]
bracket_spacing = true
int_types = "long"
line_length = 150
quote_style = "double"
tab_width = 4
Code example to reproduce the issue:
slither ./src/auction/Auction.sol
Version:
0.8.3
Relevant log output:
Compilation warnings/errors on ./src/auction/Auction.sol:
Error: Source "node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol" not found: File not found. Searched the following locations: "".
--> src/lib/interfaces/IWETH.sol:4:1:
|
4 | import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Source "node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol" not found: File not found. Searched the following locations: "".
--> src/lib/interfaces/IUUPS.sol:4:1:
|
4 | import { IERC1822Proxiable } from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Source "node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol" not found: File not found. Searched the following locations: "".
--> src/lib/proxy/ERC1967Upgrade.sol:4:1:
|
4 | import { IERC1822Proxiable } from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Source "node_modules/@openzeppelin/contracts/utils/StorageSlot.sol" not found: File not found. Searched the following locations: "".
--> src/lib/proxy/ERC1967Upgrade.sol:5:1:
|
5 | import { StorageSlot } from "@openzeppelin/contracts/utils/StorageSlot.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Source "node_modules/@openzeppelin/contracts/proxy/Proxy.sol" not found: File not found. Searched the following locations: "".
--> src/lib/proxy/ERC1967Proxy.sol:4:1:
|
4 | import { Proxy } from "@openzeppelin/contracts/proxy/Proxy.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Traceback (most recent call last):
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\platform\solc.py", line 544, in _run_solc
ret: Dict = json.loads(stdout)
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\slither\__main__.py", line 744, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\slither\__main__.py", line 76, in process_all
compilations = compile_all(target, **vars(args))
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\crytic_compile.py", line 637, in compile_all
compilations.append(CryticCompile(target, **kwargs))
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\crytic_compile.py", line 117, in __init__
self._compile(**kwargs)
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\crytic_compile.py", line 548, in _compile
self._platform.compile(self, **kwargs)
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\platform\solc.py", line 154, in compile
targets_json = _get_targets_json(compilation_unit, self._target, **kwargs)
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\platform\solc.py", line 284, in _get_targets_json
force_legacy_json=force_legacy_json,
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\platform\solc.py", line 548, in _run_solc
raise InvalidCompilation(f"Invalid solc compilation {stderr}")
crytic_compile.platform.exceptions.InvalidCompilation: Invalid solc compilation Error: Source "node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol" not found: File not found. Searched the following locations: "".
--> src/lib/interfaces/IWETH.sol:4:1:
|
4 | import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Source "node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol" not found: File not found. Searched the following locations: "".
--> src/lib/interfaces/IUUPS.sol:4:1:
|
4 | import { IERC1822Proxiable } from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Source "node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol" not found: File not found. Searched the following locations: "".
--> src/lib/proxy/ERC1967Upgrade.sol:4:1:
|
4 | import { IERC1822Proxiable } from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Source "node_modules/@openzeppelin/contracts/utils/StorageSlot.sol" not found: File not found. Searched the following locations: "".
--> src/lib/proxy/ERC1967Upgrade.sol:5:1:
|
5 | import { StorageSlot } from "@openzeppelin/contracts/utils/StorageSlot.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Source "node_modules/@openzeppelin/contracts/proxy/Proxy.sol" not found: File not found. Searched the following locations: "".
--> src/lib/proxy/ERC1967Proxy.sol:4:1:
|
4 | import { Proxy } from "@openzeppelin/contracts/proxy/Proxy.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
None
Error in ./src/auction/Auction.sol
Traceback (most recent call last):
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\platform\solc.py", line 544, in _run_solc
ret: Dict = json.loads(stdout)
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\slither\__main__.py", line 744, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\slither\__main__.py", line 76, in process_all
compilations = compile_all(target, **vars(args))
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\crytic_compile.py", line 637, in compile_all
compilations.append(CryticCompile(target, **kwargs))
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\crytic_compile.py", line 117, in __init__
self._compile(**kwargs)
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\crytic_compile.py", line 548, in _compile
self._platform.compile(self, **kwargs)
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\platform\solc.py", line 154, in compile
targets_json = _get_targets_json(compilation_unit, self._target, **kwargs)
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\platform\solc.py", line 284, in _get_targets_json
force_legacy_json=force_legacy_json,
File "c:\users\dottdav\appdata\local\programs\python\python37\lib\site-packages\crytic_compile\platform\solc.py", line 548, in _run_solc
raise InvalidCompilation(f"Invalid solc compilation {stderr}")
crytic_compile.platform.exceptions.InvalidCompilation: Invalid solc compilation Error: Source "node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol" not found: File not found. Searched the following locations: "".
--> src/lib/interfaces/IWETH.sol:4:1:
|
4 | import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Source "node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol" not found: File not found. Searched the following locations: "".
--> src/lib/interfaces/IUUPS.sol:4:1:
|
4 | import { IERC1822Proxiable } from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Source "node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol" not found: File not found. Searched the following locations: "".
--> src/lib/proxy/ERC1967Upgrade.sol:4:1:
|
4 | import { IERC1822Proxiable } from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Source "node_modules/@openzeppelin/contracts/utils/StorageSlot.sol" not found: File not found. Searched the following locations: "".
--> src/lib/proxy/ERC1967Upgrade.sol:5:1:
|
5 | import { StorageSlot } from "@openzeppelin/contracts/utils/StorageSlot.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Source "node_modules/@openzeppelin/contracts/proxy/Proxy.sol" not found: File not found. Searched the following locations: "".
--> src/lib/proxy/ERC1967Proxy.sol:4:1:
|
4 | import { Proxy } from "@openzeppelin/contracts/proxy/Proxy.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Please upgrade to the latest slither version and see if this improves the foundry compilation
The same issue is with me. And the issue still exsits in slither v0.10.0 and crytic-compile v0.3.5. The content of remappings.txt file is as follows:
hardhat/=node_modules/hardhat/
xdeployer/=node_modules/xdeployer/
forge-std/=contracts/lib/forge-std/src/
@openzeppelin/=node_modules/@openzeppelin/
ds-test/=contracts/lib/forge-std/lib/ds-test/src/
@erc6900/reference-implementation/=contracts/lib/reference-implementation/src/
@eth-infinitism/account-abstraction/=contracts/lib/account-abstraction/contracts/
when I ran slither in root dir of my project, I got an error below:
'npx hardhat clean' running (wd: /Users/ivan/Dev/gitlab/myprojects/erc6900-plugins)
'npx hardhat clean --global' running (wd: /Users/ivan/Dev/gitlab/myprojects/erc6900-plugins)
Problem deserializing hardhat configuration, using defaults: Expecting value: line 1 column 1 (char 0)
'npx hardhat compile --force' running (wd: /Users/ivan/Dev/gitlab/myprojects/erc6900-plugins)
Traceback (most recent call last):
File "/opt/homebrew/bin/slither", line 8, in <module>
sys.exit(main())
^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/slither/__main__.py", line 727, in main
main_impl(all_detector_classes=detectors, all_printer_classes=printers)
File "/opt/homebrew/lib/python3.11/site-packages/slither/__main__.py", line 833, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/slither/__main__.py", line 96, in process_all
compilations = compile_all(target, **vars(args))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/crytic_compile.py", line 718, in compile_all
compilations.append(CryticCompile(target, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/crytic_compile.py", line 207, in __init__
self._compile(**kwargs)
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/crytic_compile.py", line 629, in _compile
self._platform.compile(self, **kwargs)
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/platform/hardhat.py", line 183, in compile
hardhat_like_parsing(crytic_compile, self._target, build_directory, hardhat_working_dir)
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/platform/hardhat.py", line 97, in hardhat_like_parsing
path = convert_filename(
^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/utils/naming.py", line 169, in convert_filename
filename = _verify_filename_existence(filename, cwd)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/crytic_compile/utils/naming.py", line 119, in _verify_filename_existence
raise InvalidCompilation(f"Unknown file: {filename}")
crytic_compile.platform.exceptions.InvalidCompilation: Unknown file: @erc6900/reference-implementation/interfaces/IPlugin.sol
It seems like crytic-compile checks only from contracts and node_modules, instead from remappings.txt which redirects the path to the actually path.
Hi @TheStarBoys, you seem to be using hardhat in your case and not foundry. The compilation tool takes care of the remappings and not Slither in this case. If you intended to use foundry; do you have a foundry.toml file in /Users/ivan/Dev/gitlab/myprojects/erc6900-plugins?
Hi @TheStarBoys, you seem to be using hardhat in your case and not foundry. The compilation tool takes care of the remappings and not Slither in this case. If you intended to use foundry; do you have a
foundry.tomlfile in/Users/ivan/Dev/gitlab/myprojects/erc6900-plugins?
Yeah,it's a project using foundry and hardhat. It's both OK for compiling using forge build and npx hardhat compile individually.
crytic-compile allows to forcibly use compile tools, either hardhat Or foundry. But It is both not working for using crytic-compile. And there's the same issue mentioned above.
Would you be able to share the codebase? Generally if it builds but isn't working, there is something we need to debug with the underlying compilation framework e.g. it is providing a file path that does not exist.
I use the slither by python API. If the contract use a mappings, Slither will go wrong. The reason is also "file not found, Searched the following locations: "". The contract address is 0x51bdbfcd7656e2c25ad1bc8037f70572b7142ecc. In the Router.sol file,
import {Math} from "openzeppelin-math/Math.sol";
But the openzeppelin-math/Math.sol is remapped to lib/openzeppelin-contracts/contracts/utils/math/Math.sol I use etherscan API to download the contract source code, the file system is like https://etherscan.deth.net/address/0x51bdbfcd7656e2c25ad1bc8037f70572b7142ecc My python3 code is
from slither.slither import Slither
ctsl = Slither(file)
How to solve this remappings problem in slither API?