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

Cannot build solc on macOS #487

Closed
ryanc414 opened this issue May 5, 2020 · 5 comments · Fixed by #490
Closed

Cannot build solc on macOS #487

ryanc414 opened this issue May 5, 2020 · 5 comments · Fixed by #490
Assignees
Labels
bug Something isn't working priority Should be included in next release

Comments

@ryanc414
Copy link

ryanc414 commented May 5, 2020

Environment information

  • brownie Version: 1.8.2
  • ganache-cli Version: 6.9.1
  • solc Version: 0.4.26+commit.4563c3fc.Darwin.appleclang
  • Python Version: 3.8.2
  • OS: osx

What was wrong?

I'm trying to use Brownie on macOS Catalina 10.15.4, following this guide: https://medium.com/@iamdefinitelyahuman/ethereum-mainnet-testing-with-python-and-brownie-82a61dee0222

Unfortunately, when I try and construct a Contract it seems to fail to install solc, due to a limitation in py-solc-x. I already have solc version 0.4.26 installed via homebrew, so I'm not quite sure why brownie is trying to reinstall solc for me.

>>> address = "0xf79d6afbb6da890132f9d7c355e3015f15f3406f"
>>> oracle = Contract.from_explorer(address)

Fetching source of 0xF79D6aFBb6dA890132F9D7c355e3015f15F3406F from api.etherscan.io...
  File "<console>", line 1, in <module>
  File "brownie/network/contract.py", line 630, in from_explorer
    build = compile_and_format(sources, solc_version=str(version), optimizer=optimizer)
  File "brownie/project/compiler/__init__.py", line 112, in compile_and_format
    set_solc_version(version)
  File "brownie/project/compiler/solidity.py", line 82, in set_solc_version
    install_solc(version)
  File "brownie/project/compiler/solidity.py", line 90, in install_solc
    solcx.install_solc(str(version), show_progress=True)
  File "solcx/install.py", line 229, in install_solc
    _install_solc_osx(version, allow_osx, show_progress, solcx_binary_path)
  File "solcx/install.py", line 332, in _install_solc_osx
    raise ValueError(
ValueError: Py-solc-x cannot build solc versions 0.4.x on OSX. If you install solc 0.4.x using brew and reload solcx, the installed version will be available. See https://github.com/ethereum/homebrew-ethereum for installation instructions.

To ignore this error, include 'allow_osx=True' when calling solcx.install_solc()

How can it be fixed?

I think probably there is a bug with detecting and using my installed version of solc. If it really does need to install a different version, then maybe try passing the allow_osx=True flag as suggested in the error message?

@iamdefinitelyahuman iamdefinitelyahuman added bug Something isn't working priority Should be included in next release labels May 5, 2020
@iamdefinitelyahuman iamdefinitelyahuman self-assigned this May 5, 2020
@iamdefinitelyahuman
Copy link
Member

Hi,

Thank you for opening this issue!

This is an unfortunate limitation with OSX. Because there are no first-party OSX binaries being served, solc has to be compiled from source each time. The old 0.4.x series has compatibility issues with boost that means the build will usually fail :(

The contract in question (0xf79d6afbb6da890132f9d7c355e3015f15f3406f) was compiled using v0.4.24. To attempt to build that solc version, open the brownie console and then:

import solcx
solcx.install_solc('v0.4.24', allow_osx=True)

Alternatively: py-solc-x will try to use whichever version of solc is found via which solc, as well as any versions located in /usr/local/Cellar. I'm not using OSX so I can't say for certain, but I think brew might allow you to specifically install v0.4.24? Which would solve this issue.

I can see how all of the steps given above are less than ideal for dealing with the issue, especially from the perspective of a would-be new user. I will add a platform-specific check where contracts using 0.4.x are handled as not-compilable on OSX systems, so this issue doesn't happen again.

@ryanc414
Copy link
Author

ryanc414 commented May 5, 2020

Thanks for the quick reply! I already have version 0.4.26 of solc installed via homebrew, but the contract requires 0.4.24 - does the patch version need to match exactly?

@iamdefinitelyahuman
Copy link
Member

Yeah, what's happening is brownie tries to locally compile the contract with the exact compiler settings given by etherscan. This way we have access to information such the source map and AST, which are required for the debugging functionality. Changes in the patch version generate different bytecode, and even a slight variation can result in very strange and misleading trace outputs.

All that said, it's not mission critical. If brownie can't verify, you can still interact with the contract using the ABI. It just becomes more "trust me" exercise that etherscan is serving an accurate ABI. A warning is raised in this case.

@ryanc414
Copy link
Author

ryanc414 commented May 5, 2020

OK that makes sense, thanks for the explanation. It would be a little more user-friendly if the error message could include the exact version of solc that is missing instead of just (in this case) 0.4.x, as that gave me the impression that installing any 0.4.x version manually would make the error go away.

Overall I'm having a much easier time using brownie on Ubuntu, it all works really well so far!

@iamdefinitelyahuman
Copy link
Member

Excellent. Thanks for the feedback! I will address it in py-solc-x as well as here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority Should be included in next release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants