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:

2 Likes

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.

3 Likes

What’s the current status on M1? I think a variable is not being set properly for M1 arch, maybe? Note the URL path has a ‘//’ after “dfx”

Home | Internet Computer

script output:

curl: (1) Protocol "http" not supported or disabled in libcurl
info: Version found: 
info: Creating uninstall script in ~/.cache/dfinity
info: uninstall path=/Users/neo/.cache/dfinity/uninstall.sh
info: Checking for latest release...
curl: (1) Protocol "http" not supported or disabled in libcurl
dfinity-sdk: command failed: downloader https://sdk.dfinity.org/downloads/dfx//x86_64-darwin/dfx-.tar.gz /var/folders/5_/wnrs8wgj30gfg0v4c6gzyv_80000gn/T/tmp.e7CycqsQ/dfx.tar.

If I try the URL in a browser:

NoSuchKey The specified key does not exist.sdk/dfx/x86_64-darwin/dfx-.tar.gz0721C4H6D6MAB3MBzLrR71mH5NQCRwMSsuXN7ksW4Kq6NG4TijvdEc7hgVUSYq1dJlT0KZK8vPPXN3BdoiYHOX0faIc=

@hansl It looks like DFX_VERSION is not being set.

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

I pulled this version from the docs, and it’s now set, but now I get:

info: Version found: 0.8.1

info: Creating uninstall script in ~/.cache/dfinity

info: uninstall path=/Users/neo/.cache/dfinity/uninstall.sh

info: Checking for latest release…

curl: (1) Protocol “http” not supported or disabled in libcurl

dfinity-sdk: command failed: downloader https://sdk.dfinity.org/downloads/dfx/0.8.1/x86_64-darwin/dfx-0.8.1.tar.gz /var/folders/5_/wnrs8wgj30gfg0v4c6gzyv_80000gn/T/tmp.zb0lqylb/dfx.tar.gz

exit

I managed to download 0.8.1 manually. What’s the latest version? I will use this for now.

I used 0.8.0 version before, and upgraded it to 0.8.1 in M1 just now, it’s ok.

dfx --version
dfx 0.8.0

dfx upgrade
Current version: 0.8.0
Fetching manifest https://sdk.dfinity.org/manifest.json
New version available: 0.8.1
  Done

dfx --version
dfx 0.8.1
2 Likes