0

I recently got an M1 mac and I'm trying to compile my brownie project's contracts which compiled fine on my previous machine. I've installed Brownie v1.18.2 and when attempting to run brownie compile I get the following stack trace. A similar issue has been raised, however there isn't a satisfactory answer on how to get it working in brownie.

Downloading from https://solc-bin.ethereum.org/macosx-amd64/solc-macosx-amd64-v0.8.14+commit.80d49f37
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████| 38.4M/38.4M [00:49<00:00, 784kiB/s]
  File "brownie/_cli/__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/compile.py", line 50, in main
    proj = project.load()
  File "brownie/project/main.py", line 768, in load
    return Project(name, project_path)
  File "brownie/project/main.py", line 188, in __init__
    self.load()
  File "brownie/project/main.py", line 245, in load
    self._compile(changed, self._compiler_config, False)
  File "brownie/project/main.py", line 100, in _compile
    build_json = compiler.compile_and_format(
  File "brownie/project/compiler/__init__.py", line 105, in compile_and_format
    find_solc_versions(solc_sources, install_needed=True, silent=silent)
  File "brownie/project/compiler/solidity.py", line 173, in find_solc_versions
    install_solc(*to_install)
  File "brownie/project/compiler/solidity.py", line 105, in install_solc
    solcx.install_solc(version, show_progress=True)
  File "solcx/install.py", line 466, in install_solc
    raise exc
  File "solcx/install.py", line 459, in install_solc
    _validate_installation(version, solcx_binary_path)
  File "solcx/install.py", line 636, in _validate_installation
    raise SolcInstallationError(
SolcInstallationError: Downloaded binary would not execute, or returned unexpected output. If this issue persists, you can try to compile from source code using `solcx.compile_solc('0.8.14')`.
4
  • Did you try checking on their github repository issues? From this issue it seems it was already fixed github.com/eth-brownie/brownie/issues/1315.
    – Ismael
    Commented May 21, 2022 at 19:38
  • @Ismael I think that's a different error, I've been able to install brownie as mentioned in the question, but brownie attempts to install python solcx as that's the compiler brownie requires. I have installed solcjs(solc v0.8.14) and it works fine.
    – MShakeG
    Commented May 22, 2022 at 6:36
  • @Ismael this issue seems to be identical to mine: github.com/eth-brownie/brownie/issues/1086
    – MShakeG
    Commented May 22, 2022 at 6:48
  • 1
    I managed to get it to compile following that issue and installing python 3.8.10 using pyenv apple.stackexchange.com/a/319675/396231
    – MShakeG
    Commented May 22, 2022 at 7:08

1 Answer 1

1

I had a similar issue and ended up digging pretty deep into brownie to understand what's occurring.

Ultimately, brownie calls out to pysolcx to interact with the solidity compiler. pysolcx looks through the declarations within the contract code to determine the solidity compiler to utilize. If this version of the compiler isn't found, it calls out to download/install a proper version.
This is the point at which things go wrong. Rather than downloading a copy of solc compiled for the M1 it downloads the intel version.

There are two paths to go from here. You may be able to take the "easy way out" and install Rosetta, allowing your M1 mac to run intel binaries. Note I say may as I haven't attempted this myself.

The other route is to install the compiler yourself, and allow pysolcx to find it. This route is relatively simple, but naming convention matters.

When pysolcx installs solc it does so in a hidden 'solcx' directory in your home directory. (~/.solcx)

To resolve the issue I installed solc via homebrew:

brew tap ethereum/ethereum
brew install solidity

then symlinked the installed binary into the proper location to satisfy pysolcx

$ which solc
/opt/homebrew/bin/solc

$ solc --version
solc, the solidity compiler commandline interface
Version: 0.8.16+commit.07a7930e.Darwin.appleclang

$ pwd
/Users/username/.solcx

$ ln -s $(which solc) ./solc-v0.8.16

$ ls -l /Users/username/.solcx/*
lrwxr-xr-x  1 username  staff  22 Aug 10 18:14 /Users/username/.solcx/solc-v0.8.16 -> /opt/homebrew/bin/solc

I'm not saying any of the other answers won't resolve the issue, however I believe they may be byproducts of other testing and/or needing to install Rosetta to run intel binaries.

The reason I went this route is that it keeps everything M1 native while actually resolving the root of the issue.

1
  • I got "Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!"
    – Ender
    Commented Sep 12, 2023 at 9:15

Your Answer

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

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