amplify-cli: CLI V.8 is not working under M1

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

How did you install the Amplify CLI?

npm install -g @aws-amplify/cli

If applicable, what version of Node.js are you using?

v17.8.0

Amplify CLI Version

@newest

What operating system are you using?

macOS

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

Nope

Amplify Categories

Not applicable

Amplify Commands

Not applicable

Describe the bug

When I install the newest cli, the cli is VOID. amplify --v is not return any text. all other amplify commands too.

Expected behavior

… do something.

Reproduction steps

reInstalled macOS today and installed the cli

GraphQL schema(s)

# Put schemas below this line


Log output

# Put your logs below this line


Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 15
  • Comments: 37 (9 by maintainers)

Most upvoted comments

I am also on OSX M1 and just ran into the no output on cli v8 issue while setting up a new machine. Downgrading to v7 worked well. It feels like requiring a rosetta install to work with a newer version of cli is a step backwards. Hoping whatever dependency in v8 that seems to require rosetta can be eliminated or updated to support m1 natively.

hi @josefaidt, after installing softwareupdate --install-rosetta, amplify-cli v8 works. Thanks.

% arch
arm64

% amplify -version
8.2.0

Chip: Apple M1 Pro

% node -v
v18.2.0

% npm -v
8.9.0

% curl -sL https://aws-amplify.github.io/amplify-cli/install | bash && $SHELL
...
bash: line 111: /Users/<home folder>/.amplify/bin/amplify: Bad CPU type in executable

% npm i -g @aws-amplify/cli
added 26 packages, and audited 27 packages in 36s

% amplify # return nothing
% which amplify
/Users/<home folder>/.amplify/bin/amplify

 % /Users/<home folder>/.amplify/bin/amplify
zsh: bad CPU type in executable: /Users/<home folder>/.amplify/bin/amplify

v7 seems like working

% npm install -g @aws-amplify/cli@7 --force
% amplify -v
7.6.26

I was able to get it working by downloading amplify-pkg-macos.tgz file from releases. …

@kzetxa’s suggestion didn’t work for me, since it still downloads an x86 build, it fails with Bad CPU type in executable.

Here is the workaround I used to get cli v9 working on Mac arm64 with Rosetta. Build from source. The Max node supported version is v16.

git clone https://github.com/aws-amplify/amplify-cli.git
cd amplify-cli
nvm use 16
yarn install
yarn run build

@wderezin’s suggestion did work for me (many thanks!) with a couple of minor additions to allow the amplify command to work from anywhere. Here’s what worked for me:

$ git clone https://github.com/aws-amplify/amplify-cli.git
$ cd amplify-cli
$ git checkout v10.4.1 # Avoids building the dev branch but builds a release tag; update as necessary
$ yarn && yarn build # I'm using node 16 globally
$ rm ~/.amplify/bin/amplify
$ ln -s $(pwd)/packages/amplify-cli/bin/amplify ~/.amplify/bin/amplify

Now you can run amplify status from an amplify project and it should work.

It’s pretty frustrating that this is still required. I guess AWS expects us to brute-force the issue via Rosetta, but I haven’t needed Rosetta up until now so I’d rather avoid it.

Hey @crzyjcky can you paste the output of running arch and try installing Rosetta with softwareupdate --install-rosetta to see if this mitigates the issue?

@josefaidt here you go, Screenshot 2022-04-16 at 2 29 30 PM

and when I install using following command then amplify runs as expected.

npm install -g @aws-amplify/cli@7 --force

Screenshot 2022-04-16 at 2 32 50 PM

I’m using node 16.1.0, and I’ve installed node using asdf using following commands,

asdf plugin add nodejs
asdf install nodejs 16.1.0
asdf global nodejs 16.1.0

I’ve also tried with latest version of node directly without asdf but was still getting the same issue.

i installed the v7 and pulled my project, after that, I installed v8

@biller-aivy I’m also facing the same issue that there is no output on executing any amplify cli command, can you share how did you resolve this? Otherwise I feel like I’ll have open a new issue.

Thanks @danrivett and everyone!

Following your suggestions I managed to build the project from source without Rosetta.

I agree with @thtliife: using Rosetta doesn’t seem the right way to go.

I had to fix one thing, though, because I got some errors when invoking yarn.

I am using Node.js v19.2.0.

After checking out the desired version (git checkout v12.0.3 in my case), I had to add the following to the resolutions section of package.json:

"resolutions": {
  "nan": "2.17.0",
  ...

to force the usage of the version of the nan package (https://github.com/nodejs/nan/) in which the maintainers just fixed a bug.

The nan package is not directly required in the root package.json, but it’s required throughout the setup process.

After applying this modification, the installation and building of the project went smoothly for me.

If you link the command (ln -s...) as @danrivett suggests, you may need to add ~/.amplify/bin to your PATH:

export PATH="/Users/$USER/.amplify/bin:$PATH"

To make the addition permanent, add the command to your shell profile file (ie .zshrc or .bash_profileetc.).

Hope this helps!

Thanks @wderezin and @danrivett Building from source on my m1 machine without Rosetta installed sorted this out for me. I am trying to keep my macbook running m1 native apps only, as i believe emulating apps to be a bit of a step backwards. The information you guys provided was very valuable in keeping my system running native binaries only 😃

Here is the workaround I used to get cli v9 working on Mac arm64 with Rosetta. Build from source. The Max node supported version is v16.

git clone https://github.com/aws-amplify/amplify-cli.git
cd amplify-cli
nvm use 16
yarn install
yarn run build

You get a working amplify.

# ./node_modules/.bin/amplify --version
9.1.0

The M1, arm64, is not supported.

After several different installs attempts, the amplify binary every time it generates x86.

# file  ~/.amplify/bin/amplify
~/.amplify/bin/amplify: Mach-O 64-bit executable x86_64

If you look at at the supported platform in the binary.ts you can see the Mac arm64 package is pointed to the x64 version.

  {
    TYPE: 'Darwin',
    ARCHITECTURE: 'arm64',
    COMPRESSED_BINARY_PATH: 'amplify-pkg-macos-x64.tgz',
  },

i installed the v7 and pulled my project, after that, I installed v8

downgrading to 7.6.26 fixed the issue for me as well.

I was able to get it working by downloading amplify-pkg-macos.tgz file from releases.

I deleted the binary at /usr/local/bin/amplify, renamed the binary inside the package that I downloaded, and moved it to the location where the old deleted binary was. I noticed that I also needed to do sudo chown -R $(whoami) ~/.amplify. It seems after running amplify, I have another binary in my ~/.amplify directory.

Not sure why installing it via NPM was not working. I had no errors, just a dead binary with no output.

I am running on a 2021 Macbook Pro 16" M1 Max, with Node 16.12.0, Amplify 10.3.1, and macOS Monterey 12.6.