A trick way to run Motoko in Mac M1

I tried installing the dfx to a Mac with M1 CPU. Following the Document:

sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"

And it failed:

info: 
...
Do you agree and wish to install the DFINITY Canister SDK [y/N]?
y
dfinity-sdk: unknown CPU type: arm64
exit

As asking help before: Unrecognized OS type - #6 by flyq

Solution

Download the install.sh, modified it from:

    case "$_cputype" in
        x86_64 | x86-64 | x64 | amd64)
            _cputype=x86_64
            ;;
        *)
            err "unknown CPU type: $_cputype"
            ;;

to

    case "$_cputype" in
        x86_64 | x86-64 | x64 | amd64)
            _cputype=x86_64
            ;;
        *)
            _cputype=x86_64
            ;;

and run ./install.sh in a terminal, the dfx will be installed successfully.

After testing some examples, everything runs well. If there any problems, I will report it.

2 Likes

Actually I tried to install the SDK on M1 10 minutes ago and I didn’t even need the trick it worked natively, maybe they’ve changed something…

Thanks anyway :wink:

1 Like

We’ve updated our script last week after doing an e2e run with it on my own Mac Mini. We don’t have regular CI so it might break, but you can now install it (just like you would on Windows). It’s not officially supported yet.

2 Likes