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

FileNotFoundError: [Errno 2] No such file or directory: 'artifacts/build-info' #236

Closed
Jovonni opened this issue Jan 2, 2022 · 14 comments
Closed

Comments

@Jovonni
Copy link

Jovonni commented Jan 2, 2022

Is this following error due to my version of crytic-compile?

Command

echidna-test . --contract <Contract Name>
echidna-test: Couldn't compile given file
stdout:
stderr:
INFO:CryticCompile:'npx hardhat compile --force' running
INFO:CryticCompile:Compiling 70 files with 0.7.4
Generating typings for: 71 artifacts in dir: build/types for target: ethers-v5
Successfully generated 125 typings!
Compilation finished successfully


Traceback (most recent call last):
  File "/usr/local/bin/crytic-compile", line 33, in <module>
    sys.exit(load_entry_point('crytic-compile==0.2.2', 'console_scripts', 'crytic-compile')())
  File "/usr/local/lib/python3.9/site-packages/crytic_compile/__main__.py", line 192, in main
    compilations = compile_all(**vars(args))
  File "/usr/local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 637, in compile_all
    compilations.append(CryticCompile(target, **kwargs))
  File "/usr/local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 117, in __init__
    self._compile(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 548, in _compile
    self._platform.compile(self, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 87, in compile
    os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x))
FileNotFoundError: [Errno 2] No such file or directory: 'artifacts/build-info'

This is in the root directory btw, targeting a contract inside the /contracts/ folder

This is also posted as a comment here:
#164 (comment)

@Jovonni Jovonni changed the title (Hardhat) FileNotFoundError: [Errno 2] No such file or directory: 'artifacts/build-info' FileNotFoundError: [Errno 2] No such file or directory: 'artifacts/build-info' Jan 2, 2022
@0xalpharush
Copy link
Contributor

0xalpharush commented Jan 3, 2022

Crytic-compile looks for build artifacts in artifacts/build-info by default. Can you verify that npx hardhat compile . produces artifacts in that location? If you're using a custom path you can use

echidna-test . --contract <Contract Name> --crytic-args "--hardhat-artifacts-directory <your-path>"

@Jovonni
Copy link
Author

Jovonni commented Jan 3, 2022

Crytic-compile looks for build artifacts in artifacts/build-info by default. Can you verify that npx hardhat compile . produces artifacts in that location? If you're using a custom path you can use

echidna-test . --contract <Contract Name> --crytic-args "--hardhat-artifacts-directory <your-path>"

Good call, that worked, thanks @0xalpharush . Another quick question. I am now getting after correcting the build-info location in the command above:

echidna-test: invalid character at offset: 630
CallStack (from HasCallStack):
  error, called at src/EVM/Solidity.hs:518:13 in hevm-0.48.0-3yc97MaS5pIDvLZRLvuryr:EVM.Solidity

From what I see, this is associated with hevm. Is this coming from one of the json files located in build-info/? I haven't seen this error before.

@Jovonni
Copy link
Author

Jovonni commented Jan 3, 2022

I'm thinking it could be something in the contracts that the JSON structure is having a problem parsing @0xalpharush. I don't know if crytic-compile or echidna is returning the whole error stack trace or not.

@0xalpharush
Copy link
Contributor

Can you run crytic-compile --version and verify that you're using 0.2.2? Then, please try npx hardhat clean . and run Echidna again

@ggrieco-tob
Copy link
Member

@Jovonni I think you can solve your JSON issue doing:

  1. npx hardhat clean .
  2. rm -Rf crytic-export

Then recompile and rerun echidna as you did before.

@Jovonni
Copy link
Author

Jovonni commented Jan 4, 2022

I am using 0.2.2 @0xalpharush

For some reason @ggrieco-tob npx hardhat clean . returns:

Error HH308: Unrecognized positional argument .

For more info go to https://hardhat.org/HH308 or run Hardhat with --show-stack-traces

However, just running npx hardhat clean works without the .

Even after removing the crytic-export directory, I am still getting:

echidna-test: invalid character at offset: 630
CallStack (from HasCallStack):
  error, called at src/EVM/Solidity.hs:518:13 in hevm-0.48.0-3yc97MaS5pIDvLZRLvuryr:EVM.Solidity

I also tried using the docker container, and same issue.

@Jovonni
Copy link
Author

Jovonni commented Jan 4, 2022

I can post this in the Echidna, but I have issues with using Echidna with contracts that have imports, that are not local. For example, something from @openzepplin, etc

Another issue I keep seeing is the:

echidna-test: No tests found in ABI

I am wondering if the no tests issue is due to no method existing with a specific echidna prefix

I don't see a level of consistency between different projects using the same frameworks (hardhat, truffle). I am wondering how this could be improved.

@ggrieco-tob
Copy link
Member

Let's fix this first:

I can post this in the Echidna, but I have issues with using Echidna with contracts that have imports, that are not local.

Are you using Docker?

@Jovonni
Copy link
Author

Jovonni commented Jan 4, 2022

Yes, I have been using both. Just to try to get one working. @ggrieco-tob

@joebb10
Copy link

joebb10 commented Sep 26, 2022

Hi! Any other solution? I'm also getting the same error and don't know what to do

@0xalpharush
Copy link
Contributor

Was this fixed @ggrieco-tob

@ggrieco-tob
Copy link
Member

ggrieco-tob commented Jan 3, 2023

I don't know. @elopez can you take a quick look to this?

@nuliknol
Copy link

nuliknol commented Apr 6, 2023

Hi! Any other solution? I'm also getting the same error and don't know what to do

yeah, have you made methods that start with echidna_ prefix ???
@joebb10

@elopez
Copy link
Member

elopez commented Apr 6, 2023

The original issue here should no longer be a problem starting with crytic-compile 0.3.0, now that we have auto-detection of the hardhat artifact directory, so I'll close this. If you encounter any other problems feel free to post on discussions or create a new issue.

@elopez elopez closed this as completed Apr 6, 2023
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

6 participants