cleanunicorn / mythos

CLI client for the MythX API
https://mythx.io/
20 stars 6 forks source link

Compiler fails to find contracts in other folders[BUG] #42

Closed JoseMiguelHerrera closed 5 years ago

JoseMiguelHerrera commented 5 years ago

I'm able to get the tool working with simple contracts, but when I try using it on contracts with a more complex folder structure, the compilation fails.

For example, the structure is:

/contracts /A.sol /sub/ /B.sol

so I can analyze A, but when I try to analyze B, which imports A, I get this:

mythos analyze ./B.sol B Reading contract ./B.sol... done › Error: ./B.sol:4:1: ParserError: Source "A.sol" not found: ENOENT: no such file or directory, stat 'A.sol' › import "../A.sol"; › ^-------------------------^

I can compile everywhere else, truffle, VS code, and remix, so not sure what's going on. I'm doing this on MacOS

Cheers

cleanunicorn commented 5 years ago

@JoseMiguelHerrera

Can you give more info on what's happening?

a.sol

import "./b.sol";

contract A is B {}

b.sol

contract B {}
JoseMiguelHerrera commented 5 years ago

I did some playing around with your simplified example above and the solution was to call the mythos command at the root of the contracts folder. It would fail if you run it in a sub folder, seems the compiler can't go up in the folder structure to look for other contracts.

for example:

in coin.sol import "../dependancy.sol"

(running in root) mythos analyze ./token/coin.sol Coin (OK) (running in root/token) mythos analyze ./coin.sol Coin (ERROR, can't find dependancy.sol in root)

cleanunicorn commented 5 years ago

Thanks for the info. There's some weird (and inconsistent) behavior I get from solc when I need to identify the imports, it behaves differently on different operating systems.