3

Follow the procedures on this page brownie : create new project and compile with brownie. Encounter the following error, please comment how to fix it.

Configuration and environment.

  1. Python 3.7.7

  2. ganache-cli 6.14.5

    (.token-venv) MacBookPro:token nelson$ brownie compile 
      Brownie v1.9.2 - Python development framework for Ethereum
      .....   
    
      [ 60%] Linking CXX executable solc
      File "brownie/_cli/__main__.py", line 58, in main
        importlib.import_module(f"brownie._cli.{cmd}").main()
      File "brownie/_cli/compile.py", line 37, in main
        project.load()
      File "brownie/project/main.py", line 656, in load
        return Project(name, project_path)
      File "brownie/project/main.py", line 160, in __init__
        self.load()
      File "brownie/project/main.py", line 213, in load
        self._compile(changed, self._compiler_config, False)
      File "brownie/project/main.py", line 96, in _compile
        optimizer=compiler_config["solc"].get("optimizer", None),
      File "brownie/project/compiler/__init__.py", line 97, in compile_and_format
        find_solc_versions(solc_sources, install_needed=True, silent=silent)
      File "brownie/project/compiler/solidity.py", line 158, in find_solc_versions
        install_solc(*to_install)
      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 374, in _install_solc_osx
        "".format(cmd[0], e.returncode)
    OSError: make returned non-zero exit status 2 while attempting to build solc from the source.
    This is likely due to a missing or incorrect version of a build dependency.
    
    For suggested installation options: https://github.com/iamdefinitelyahuman/py-solc-x/wiki/Installing-Solidity-on-OSX
    

1 Answer 1

2

The issue is coming from a dependency of Brownie called py-solc-x. From the py-solc-x wiki:

The Solidity team does not provide binaries for use with macOS/Darwin. For this reason, py-solc-x attempts to install Solidity on OSX by building it from the source code. Sometimes older versions of Solidity fail to build due to incompatible versions of one or more dependencies.

There are two possible solutions:

  1. Build via brew
  2. Use 3rd-party precompiled binaries

1. Building via Homebrew

Brownie will make use of any Solidity versions installed using brew:

brew update
brew upgrade
brew tap ethereum/ethereum
brew install solidity

To install the most recent 0.4.x / 0.5.x version of Solidity you can also use brew install solidity@4 and brew install solidity@5, respectively.

To install an older version, you can use a Homebrew formula directly from Github:

  1. Find the commit in ethereum/homebrew-ethereum which references the version you wish to install
  2. Navigate the repository until you have the raw file link for solidity.rb at that commit.
  3. Install it using brew:
brew unlink solidity
# e.g. to install v0.5.6
brew install https://raw.githubusercontent.com/ethereum/homebrew-ethereum/1ecf6c60875740133ee51f6167aef9a4f05986e7/solidity.rb

2. Installing Third-Party Binaries

The web3j team provides compiled OSX binaries for many versions of Solidity. To use a third-party binary:

  1. Download the desired version from web3j/solidity-darwin-binaries
  2. Rename the file to solc-v0.x.y where x and ycorrespond to the minor and patch version.
  3. Move the file to the ~/.solcx directory on your system. It will now be available for use in Brownie.
1
  • "Brownie compile" is incompatible with Solidity version "0.6.9" but compile successfully after install the most recent version of solidity@5 (0.5.17). Thanks for your help. Jun 10, 2020 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.