slither icon indicating copy to clipboard operation
slither copied to clipboard

Traceback Error after running "slither contracts/File.sol " command

Open daniel234x opened this issue 5 years ago • 20 comments

traceback error, After runnig the "slither contracts/File.sol" command as specified in the repo. please what should i do ?

Traceback (most recent call last):
  File "C:\Users\\AppData\Roaming\Python\Python39\site-packages\crytic_compile\platform\solc.py", line 243, in get_version
    process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
  File "C:\Users\\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\OCHAI DAVID\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\slither\__main__.py", line 712, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\slither\__main__.py", line 71, in process_all
    compilations = compile_all(target, **vars(args))
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\crytic_compile\crytic_compile.py", line 1076, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
  File "C:\Users\OCHAI DAVID\AppData\Roaming\Python\Python39\site-packages\crytic_compile\crytic_compile.py", line 137, in __init__
    self._compile(**kwargs)
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\crytic_compile\crytic_compile.py", line 987, in _compile
    self._platform.compile(self, **kwargs)
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\crytic_compile\platform\solc.py", line 144, in compile
    targets_json = _run_solc(
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\crytic_compile\platform\solc.py", line 303, in _run_solc
    compiler="solc", version=get_version(solc, env), optimized=is_optimized(solc_arguments)
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\crytic_compile\platform\solc.py", line 246, in get_version
    raise InvalidCompilation(error)
crytic_compile.platform.exceptions.InvalidCompilation: [WinError 2] The system cannot find the file specified
ERROR:root:None
ERROR:root:Error in ufragments.sol
ERROR:root:Traceback (most recent call last):
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\crytic_compile\platform\solc.py", line 243, in get_version
    process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
  File "C:\UsersAppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\slither\__main__.py", line 712, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\slither\__main__.py", line 71, in process_all
    compilations = compile_all(target, **vars(args))
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\crytic_compile\crytic_compile.py", line 1076, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\crytic_compile\crytic_compile.py", line 137, in __init__
    self._compile(**kwargs)
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\crytic_compile\crytic_compile.py", line 987, in _compile
    self._platform.compile(self, **kwargs)
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\crytic_compile\platform\solc.py", line 144, in compile
    targets_json = _run_solc(
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\crytic_compile\platform\solc.py", line 303, in _run_solc
    compiler="solc", version=get_version(solc, env), optimized=is_optimized(solc_arguments)
  File "C:\Users\AppData\Roaming\Python\Python39\site-packages\crytic_compile\platform\solc.py", line 246, in get_version
    raise InvalidCompilation(error)
crytic_compile.platform.exceptions.InvalidCompilation: [WinError 2] The system cannot find the file specified

daniel234x avatar Mar 19 '21 12:03 daniel234x

I am facing a similar issue, if not the same. It worked at some point for me, but then I migrated from Truffle to Hardhat and upgraded Python to 3.9 and now, for the love of me, I can't run it anymore.

piskel avatar Apr 11 '21 15:04 piskel

In fact, here is what I get when I try to run slither with the VSCode extension (the one from Trail of Bits). I get this whether I specify the compiler path or not.

⸻ Analysis: 0 succeeded, 1 failed, 0 skipped ⸻
Refreshing explorer...
Loaded 0 issues, displaying 0
⸻ Starting analysis ⸻
Error: Error in workspace "c:\Users\me\Documents\Projects\Blockchain\Project1":
Traceback (most recent call last):
  File "c:\users\me\appdata\local\programs\python\python39\lib\site-packages\slither\__main__.py", line 721, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "c:\users\me\appdata\local\programs\python\python39\lib\site-packages\slither\__main__.py", line 71, in process_all
    compilations = compile_all(target, **vars(args))
  File "c:\users\me\appdata\local\programs\python\python39\lib\site-packages\crytic_compile\crytic_compile.py", line 1076, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
  File "c:\users\me\appdata\local\programs\python\python39\lib\site-packages\crytic_compile\crytic_compile.py", line 137, in __init__
    self._compile(**kwargs)
  File "c:\users\me\appdata\local\programs\python\python39\lib\site-packages\crytic_compile\crytic_compile.py", line 987, in _compile
    self._platform.compile(self, **kwargs)
  File "c:\users\me\appdata\local\programs\python\python39\lib\site-packages\crytic_compile\platform\hardhat.py", line 68, in compile
    process = subprocess.Popen(
  File "c:\users\me\appdata\local\programs\python\python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "c:\users\me\appdata\local\programs\python\python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified


⸻ Analysis: 0 succeeded, 1 failed, 0 skipped ⸻
Refreshing explorer...
Loaded 0 issues, displaying 0

piskel avatar Apr 11 '21 15:04 piskel

Sorry for bumping (after 2 years lol), but this happened to me too, the error message is almost exactly the same (except for the locations). I'm using Hardhat and Python 3.9, plz fix

Traceback (most recent call last):
  File "c:\users\dev\appdata\local\programs\python\python39\lib\site-packages\slither\__main__.py", line 723, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "c:\users\dev\appdata\local\programs\python\python39\lib\site-packages\slither\__main__.py", line 71, in process_all
    compilations = compile_all(target, **vars(args))
  File "c:\users\dev\appdata\local\programs\python\python39\lib\site-packages\crytic_compile\crytic_compile.py", line 489, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
  File "c:\users\dev\appdata\local\programs\python\python39\lib\site-packages\crytic_compile\crytic_compile.py", line 109, in __init__
    self._compile(**kwargs)
  File "c:\users\dev\appdata\local\programs\python\python39\lib\site-packages\crytic_compile\crytic_compile.py", line 417, in _compile
    self._platform.compile(self, **kwargs)
  File "c:\users\dev\appdata\local\programs\python\python39\lib\site-packages\crytic_compile\platform\hardhat.py", line 66, in compile
    with subprocess.Popen(
  File "c:\users\dev\appdata\local\programs\python\python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "c:\users\dev\appdata\local\programs\python\python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified```

cybertelx avatar Jun 13 '21 15:06 cybertelx

I'm getting the same issue, someone have fixed?

alfonsograziano avatar Aug 29 '21 15:08 alfonsograziano

Same issue here, any suggestions? Currently running python3.9 which could be an issue

ghost avatar Sep 18 '21 21:09 ghost

same issue

nazhG avatar Oct 06 '21 02:10 nazhG

same issue

biddls avatar Oct 07 '21 17:10 biddls

Joining the party, same issue! Double checked all my microsoft SDK & local env variables, nothing wrong.

Bingcoin avatar Oct 09 '21 11:10 Bingcoin

Same problem here

Kayaba-Attribution avatar Nov 06 '21 16:11 Kayaba-Attribution

If you add parameter --ignore-compile then pass. But it is not workaround i think.

WojcikMM avatar Nov 12 '21 17:11 WojcikMM

ı have same problem here

ozgurk78 avatar Nov 15 '21 22:11 ozgurk78

I had the same problem. In order to temporarily circumvent this issue, I used Windows Subsystem for Linux (WSL). Specifically, the Ubuntu distribution. My setup is a Hardhat project. I did the following:

Install Slither:

sudo apt update && sudo apt upgrade
sudo apt install python3.8
pip3 install slither-analyzer

To check the Python version, run:

python3 -V

Install nodejs (v16.x):

curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -
sudo apt install -y nodejs

To check the nodejs version, run:

node -v

Install the npm dependencies of the project:

npm i

Run Slither 🎉:

slither .

pcaversaccio avatar Dec 03 '21 16:12 pcaversaccio

Same issue.

DukeCaesar avatar Jan 18 '22 12:01 DukeCaesar

Same issue.

hake-stake avatar Mar 18 '22 17:03 hake-stake

Ive found the solution that worked for me. Run the following:

  1. pip install solc-select (For windows: pip install solc-select==1.0.0b1)
  2. solc-select install 0.8.10
  3. solc-select use 0.8.10

Then youre good. Make sure youre running slither in the root folder of your project like so:

C:\Users\Username\MyProject> slither contracts/RaidersNFT.sol

emangarciano avatar Apr 13 '22 22:04 emangarciano

Hi everyone! Slither 0.8.3 and crytic-compile 0.2.3 have now been released and should resolve this problem on Windows. I'll close this issue, but feel free to create a new one if you still experience problems after upgrading both slither and crytic-compile to the latest releases.

NB: If you are using solc-select, remember to install the beta version for Windows support (pip install solc-select==1.0.0b1)

elopez avatar Apr 21 '22 17:04 elopez

Confirmed - I upgraded slither and crytic-compile to the latest versions on Windows (recommend first to remove slither and crytic-compile from the system in order to have a clean latest version) and everything worked smoothly. Thanks for fixing this!

pcaversaccio avatar Apr 21 '22 17:04 pcaversaccio

Still facing the issue with the latest version v0.8.3. Please help, there is no clear resolution for this.

Traceback (most recent call last): File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/__main__.py", line 755, in main_impl ) = process_all(filename, args, detector_classes, printer_classes) File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/__main__.py", line 87, in process_all ) = process_single(compilation, args, detector_classes, printer_classes) File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/__main__.py", line 70, in process_single slither = Slither(target, ast_format=ast, **vars(args)) File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/slither.py", line 95, in __init__ parser.parse_top_level_from_loaded_json(ast, path) File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/solc_parsing/slither_compilation_unit_solc.py", line 211, in parse_top_level_from_loaded_json contract.set_offset(top_level_data["src"], self._compilation_unit) File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/core/source_mapping/source_mapping.py", line 124, in set_offset self._source_mapping = self._convert_source_mapping(offset, compilation_unit) File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/core/source_mapping/source_mapping.py", line 101, in _convert_source_mapping (lines, starting_column, ending_column) = self._compute_line( File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/core/source_mapping/source_mapping.py", line 43, in _compute_line end_line, ending_column = compilation_unit.core.crytic_compile.get_line_from_offset( File "/Users/yohan/Library/Python/3.8/lib/python/site-packages/crytic_compile/crytic_compile.py", line 291, in get_line_from_offset return lines_delimiters[offset] KeyError: 566 None Error in . Traceback (most recent call last): File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/__main__.py", line 755, in main_impl ) = process_all(filename, args, detector_classes, printer_classes) File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/__main__.py", line 87, in process_all ) = process_single(compilation, args, detector_classes, printer_classes) File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/__main__.py", line 70, in process_single slither = Slither(target, ast_format=ast, **vars(args)) File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/slither.py", line 95, in __init__ parser.parse_top_level_from_loaded_json(ast, path) File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/solc_parsing/slither_compilation_unit_solc.py", line 211, in parse_top_level_from_loaded_json contract.set_offset(top_level_data["src"], self._compilation_unit) File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/core/source_mapping/source_mapping.py", line 124, in set_offset self._source_mapping = self._convert_source_mapping(offset, compilation_unit) File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/core/source_mapping/source_mapping.py", line 101, in _convert_source_mapping (lines, starting_column, ending_column) = self._compute_line( File "/Library/Python/3.8/site-packages/slither_analyzer-0.8.3-py3.8.egg/slither/core/source_mapping/source_mapping.py", line 43, in _compute_line end_line, ending_column = compilation_unit.core.crytic_compile.get_line_from_offset( File "/Users/yohan/Library/Python/3.8/lib/python/site-packages/crytic_compile/crytic_compile.py", line 291, in get_line_from_offset return lines_delimiters[offset] KeyError: 566

yohanelly95 avatar Aug 02 '22 05:08 yohanelly95

facing the same issue, Foundry project, running on Docker with ubuntu:22.04 windows host, slither version 0.9.1.

Error: Source "@openzeppelin/contracts/token/ERC20/IERC20.sol" not found: File not found.
 --> src/Contract.sol:4:1:
  |
4 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Error: Source "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol" not found: File not found.
 --> src/Contract.sol:5:1:
  |
5 | import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
  | ^^^^^^^^^^^^

project compiles and finishes test suite fine when running forge build/forge test

UPDATE

got this to work by ditching Foundry's remappings - instead of importing using a relative path or remappings, try setting the path to an absolute path (relative to repo root).

johnnyonline avatar Nov 10 '22 20:11 johnnyonline

renistall freshh install and other methods dont work! same issus

Nic3b avatar Jan 31 '23 22:01 Nic3b