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

Failing with FileNotFoundError: [Errno 2] No such file or directory: '/github/workspace/artifacts/build-info' #56

Open
Phips0812 opened this issue Apr 28, 2023 · 7 comments

Comments

@Phips0812
Copy link

I am using crytic/slither-action@v0.3.0 within my GitHub Actions and it worked like a charm until a few day ago.

Since it few days it's failing with the following error. I think it is related that one step is not waiting for the other as it can also be seen in the snippet below.
npx hardhat compile --force is running and normally there should come the output of the compilation. However it directly tries to find /github/workspace/artifacts/build-info which is not there yet.

'npx hardhat compile --force' running
Automining active
Automining active
Downloading compiler 0.8.16

You are using a version of Node.js that is not supported by Hardhat, and it may work incorrectly, or not work at all.

Please, make sure you are using a supported version of Node.js.

To learn more about which versions of Node.js are supported go to https://hardhat.org/nodejs-versions

Traceback (most recent call last):
  File "/opt/slither/lib/python3.9/site-packages/slither/__main__.py", line 837, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/opt/slither/lib/python3.9/site-packages/slither/__main__.py", line 90, in process_all
    compilations = compile_all(target, **vars(args))
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 643, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 131, in __init__
    self._compile(**kwargs)
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 553, in _compile
    self._platform.compile(self, **kwargs)
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 195, in compile
    hardhat_like_parsing(crytic_compile, self._target, build_directory, hardhat_working_dir)
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 49, in hardhat_like_parsing
    os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x))
FileNotFoundError: [Errno 2] No such file or directory: '/github/workspace/artifacts/build-info'
ERROR:root:Error in .
ERROR:root:Traceback (most recent call last):
  File "/opt/slither/lib/python3.9/site-packages/slither/__main__.py", line 837, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/opt/slither/lib/python3.9/site-packages/slither/__main__.py", line 90, in process_all
    compilations = compile_all(target, **vars(args))
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 643, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 131, in __init__
    self._compile(**kwargs)
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 553, in _compile
    self._platform.compile(self, **kwargs)
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 195, in compile
    hardhat_like_parsing(crytic_compile, self._target, build_directory, hardhat_working_dir)
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 49, in hardhat_like_parsing
    os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x))
FileNotFoundError: [Errno 2] No such file or directory: '/github/workspace/artifacts/build-info'
@elopez
Copy link
Member

elopez commented Apr 28, 2023

HI @Phips0812, thanks for the report! We have seen this happening a few times in the recent weeks but we have not been able to pinpoint what causes it. There have been no new Slither nor action releases in these last few days, so it's probably not something that changed in Slither or Crytic-compile. Have you upgraded anything else on your project recently? (e.g. solc version in your config, hardhat version, npm dependencies, node version in CI, etc?)

For reference, this is the code that invokes Hardhat. It uses communicate() which should wait until the process exits, so it's possible Hardhat is just failing silently and not producing the artifacts:

https://github.com/crytic/crytic-compile/blob/master/crytic_compile/platform/hardhat.py#L177-L193

I see there is also this warning being printed from your Hardhat:

You are using a version of Node.js that is not supported by Hardhat, and it may work incorrectly, or not work at all.

Please, make sure you are using a supported version of Node.js.

To learn more about which versions of Node.js are supported go to https://hardhat.org/nodejs-versions

If you could try using a supported version (see the node-version option in the action to change it) and confirm if you can reproduce the issue still, that would be great.

Thanks again!

@frangio
Copy link

frangio commented Apr 28, 2023

We get this too... (Example)

It doesn't happen consistently, so it sounds like a race condition of some kind.

@elopez
Copy link
Member

elopez commented Apr 28, 2023

Looking at the Hardhat issue tracker, this might be related: NomicFoundation/hardhat#3877

@Phips0812
Copy link
Author

@elopez thanks for the quick response! I will try to change to a supported node version asap.

However some more info: Like mentioned by @frangio this also happens randomly on our side. Sometimes if I rerun the GitHub Actions it works in the second or third run.

@mattiascaricato
Copy link

Same issue here. The only difference is that – so far – it happens always, not randomly, as mentioned above. I'm using slither-action v0.3.0 with latest Node LTS (18) + Solidity compiler v0.8.17

Regarding this error: You are using a version of Node.js that is not supported by Hardhat, and it may work incorrectly, or not work at all.

All you need to do is add node's version when you are defining the step. Like this:

- name: Run Static Analysis (Slither)
  uses: crytic/slither-action@v0.3.0
  with:
    node-version: 18

@Phips0812
Copy link
Author

Setting the node-version for slither to 18.15 seems to fix this for now:

- name: Run Static analysis
  uses: crytic/slither-action@v0.3.0
  with:
    node-version: 18.15

Thanks @frangio for the mentioned commit.

@0xmichalis
Copy link

We also started seeing this issue recently with crytic/slither-action@0.2.0. It occurs inconsistently.

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

5 participants