crytic / solc-select

Manage and switch between Solidity compiler versions
GNU Affero General Public License v3.0
752 stars 100 forks source link

[Bug-Candidate]: solc() function seems to construct a wrong solc path on Mac ARM (m1 pro) #211

Closed shuo-young closed 7 months ago

shuo-young commented 7 months ago

Describe the issue:

The solc-select v1.0.x seems to have a path concatenation problem on Mac ARM (m1 pro in my case). When I see the solc() function, I figure out it is a problem of the path which uses joinpath of two solc-{version}. The problem is solved when I just change the code to path = ARTIFACTS_DIR.joinpath(f"solc-{version}").

I think https://github.com/crytic/solc-select/issues/131#issue-1465015437 has the same problem I encountered. But this bug did not occur when I used v0.2.1 previously.

Code example to reproduce the issue:

Bug yields using join path of f"solc-{version}".

def solc() -> None:
    res = current_version()
    if res:
        (version, _) = res
        path = ARTIFACTS_DIR.joinpath(f"solc-{version}", f"solc-{version}")
        halt_old_architecture(path)
        halt_incompatible_system()
        try:
            subprocess.run(
                [str(path)] + sys.argv[1:],
                check=True,
            )
        except subprocess.CalledProcessError as e:
            sys.exit(e.returncode)
    else:
        sys.exit(1)

The error exists in halt_old_architecture(path).

Traceback (most recent call last):
  File "/Users/shall/anaconda3/bin/solc", line 8, in <module>
    sys.exit(solc())
  File "/Users/shall/anaconda3/lib/python3.8/site-packages/solc_select/__main__.py", line 91, in solc
    halt_old_architecture(path)
  File "/Users/shall/anaconda3/lib/python3.8/site-packages/solc_select/solc_select.py", line 30, in halt_old_architecture
    raise argparse.ArgumentTypeError(
argparse.ArgumentTypeError: solc-select is out of date. Please run `solc-select upgrade`

However, when I just use:

path = ARTIFACTS_DIR.joinpath(f"solc-{version}")

It works fine.

Version:

1.0.3

Relevant log output:

No response

elopez commented 7 months ago

Hi @shuo-young! v0.2.1 had a different way of storing the binaries. The newer releases use a new folder layout to store the compilers, and a mechanism to migrate over to the new format was added via solc-select upgrade. It sounds like you upgraded your solc-select installation to v1.0.3 but have not yet run solc-select upgrade to upgrade to the new on-disk format, could you try that and see if it helps?

shuo-young commented 7 months ago

Hi @shuo-young! v0.2.1 had a different way of storing the binaries. The newer releases use a new folder layout to store the compilers, and a mechanism to migrate over to the new format was added via solc-select upgrade. It sounds like you upgraded your solc-select installation to v1.0.3 but have not yet run solc-select upgrade to upgrade to the new on-disk format, could you try that and see if it helps?

Thanks for your reply and I figured it out.