ApeWorX / py-solc-x

Python wrapper and version management tool for the solc Solidity compiler.
https://solcx.readthedocs.io/
MIT License
138 stars 48 forks source link

solcx wrapper misinterpreting solc --help return code #132

Open boxydog opened 2 years ago

boxydog commented 2 years ago

Environment information

What was wrong?

Code (pretty much straight from https://web3py.readthedocs.io/en/stable/contracts.html):

    source = open('solidity/contracts/Greeter.sol').read()
    compiled_sol = solcx.compile_source(source)

Expected output: no errors Actual output: solc returned 0, solc_wrapper expected 1 from help, so it throws an error

Abbreviated output:

solcx.exceptions.SolcError: An error occurred during execution
> command: `/Users/zzz/.solcx/solc-v0.8.10 --help -`
> return code: `0`
> stdout:
solc, the Solidity commandline compiler.

...

Test outside of solcx showing solc returns 0:

$ /Users/zzz/.solcx/solc-v0.8.10 --help -
solc, the Solidity commandline compiler.
...

$ echo $?
0

Full output attached: eth1.txt

How can it be fixed?

Change solc_wrapper to always expect 0 at this line?

cameel commented 2 years ago

Just a heads up - older solc versions do return 1 from --help. The change is pretty fresh - it has been fixed in 0.8.10, which was just released (see https://github.com/ethereum/solidity/pull/12118).

It should have been 0 for --help all along since the compiler really does what is requested and it's not a failure. The only reason it was counted as one was that it was being handled by the same code that detects no arguments and prints help. No arguments on the command line is a case where we do want an error - it's still one, even on 0.8.10.