Amplify-cli: Not possible to do init headless

Created on 29 Nov 2019  Ā·  25Comments  Ā·  Source: aws-amplify/amplify-cli

Describe the bug
In my CodeBuild, i'm installing amplify then initializing it with headless mode but it crash with this error:

Scanning for plugins... 
Plugin scan successful 
Note: It is recommended to run this command from the root of your app directory 
Using default provider  undefined 
init failed 
TypeError [ERR_INVALID_ARG_TYPE]: The 'request' argument must be string. Received type undefined 
    at providers.forEach.provider (/usr/local/share/.config/yarn/global/node_modules/@aws-amplify/cli/lib/lib/init-steps/s2-initProviders.js:22:36) 
    at Array.forEach (<anonymous>) 
    at /usr/local/share/.config/yarn/global/node_modules/@aws-amplify/cli/lib/lib/init-steps/s2-initProviders.js:21:19 
    at Generator.next (<anonymous>) 
    at fulfilled (/usr/local/share/.config/yarn/global/node_modules/@aws-amplify/cli/lib/lib/init-steps/s2-initProviders.js:5:58) 

Amplify CLI Version
4.2.0

To Reproduce
Here is my config for headless init (i copied it from the doc):

#!/bin/bash 
set -e
IFS='|'

export REACTCONFIG="{\
\"SourceDir\":\"src\",\
\"DistributionDir\":\"build\",\
\"BuildCommand\":\"npm run-script build\",\
\"StartCommand\":\"npm run-script start\"\
}"

export AWSCLOUDFORMATIONCONFIG="{\
\"configLevel\":\"project\",\
\"useProfile\":false,\
\"profileName\":\"default\",\
\"accessKeyId\":\"$AWS_ACCESS_KEY_ID\",\
\"secretAccessKey\":\"$AWS_SECRET_ACCESS_KEY\",\
\"region\":\"ap-southeast-1\"\
}"

export FRONTEND="{\
\"frontend\":\"javascript\",\
\"framework\":\"react\",\
\"config\":$REACTCONFIG\
}"

export AMPLIFY="{\
\"projectName\":\"myproject\",\
\"envName\":\"$DEPLOY_ENV\",\
\"defaultEditor\":\"code\"\
}"


export PROVIDERS="{\
\"awscloudformation\":$AWSCLOUDFORMATIONCONFIG\
}"

amplify init \
--amplify $AMPLIFY \
--frontend $FRONTEND \
--providers $PROVIDERS \
--yes

I've printed all env and printed the result and all are normal and rightly formated json.

Expected behavior
It should work :)

Desktop (please complete the following information):

  • Node 10
  • Linux Amazon
pending-response pending-triage platform

Most helpful comment

I found the "problem". It seems that installing amplify-cli with yarn globally is not ok...

I just changed to npm install -g @aws-amplify/cli --unsafe-perm=true and it worked...

All 25 comments

Please get the latest CLI, run amplify plugin scan and try again. Let us know if the issue is still there.

Issue is still here :(

Scanning for plugins... 
Plugin scan successful 
Scanning for plugins... 
Plugin scan successful 
Note: It is recommended to run this command from the root of your app directory 
Using default provider  undefined 
init failed 
TypeError [ERR_INVALID_ARG_TYPE]: The 'request' argument must be string. Received type undefined 
    at providers.forEach.provider (/usr/local/share/.config/yarn/global/node_modules/@aws-amplify/cli/lib/lib/init-steps/s2-initProviders.js:22:36) 
    at Array.forEach (<anonymous>) 
    at /usr/local/share/.config/yarn/global/node_modules/@aws-amplify/cli/lib/lib/init-steps/s2-initProviders.js:21:19 
    at Generator.next (<anonymous>) 
    at fulfilled (/usr/local/share/.config/yarn/global/node_modules/@aws-amplify/cli/lib/lib/init-steps/s2-initProviders.js:5:58) 
    at process._tickCallback (internal/process/next_tick.js:68:7) 

I ran amplify plugin scan before the init.

Any news on this error?
This is blocking our CI/CD process...

Thanks,
Sebastien

@UnleashedMind Did you get a chance to take a look at this? ^

We have a PR out for it already, but it's not merged yet.
https://github.com/aws-amplify/amplify-cli/pull/2907
But the PR only prevents the incorrect prompt for selection or require the non-existing provider plugin, or require an "undefined" plugin package. The root cause is the awscloudformation plugin is missing.
@SebSchwartz let me gather some more info:

  • what is the CLI version? (run amplify -v to find out)
  • run amplify plugin scan and then amplify plugin list, select active plugins , tell us what are there, and if awscloudformation is in the list.

Hi,

Here is the results of the commands:

v10.17.0 - Node version
6.11.3  - NPM Version
Scanning for plugins... 
Plugin scan successful 
4.6.0 - Amplify version
Scanning for plugins... 
Plugin scan successful 
? Select the section to list (Use arrow keys) 
āÆ active plugins  
  excluded plugins  
  general information Ā·[22DĀ·[22CĀ·[2KĀ·[1AĀ·[2KĀ·[1AĀ·[2KĀ·[1AĀ·[2KĀ·[G? Select the section to list active pluginsĀ·[43DĀ·[43C 
 all 
core 
  analytics 
 api 
  auth 
  function 
  hosting
interactions 
  notifications 
  predictions 
 storage 
  xr 
  codegen 
  android
ios 
  javascript 
  awscloudformation 
 mock 


then you should be fine now, are you still having the issue?

Yes still the same issue :(

@UnleashedMind Still the issue in 4.6.0. Our CI/CD is still not building and our customer is not very happy with that :(

Same here

@SebSchwartz fwiw I got this working by installing aws-amplify/cli globally and running it that way. But I also did not have the plugins you have listed when I checked.

@chadkouse What do you mean by "running it that way"?

@kaustavghosh06 any news on that? I just copied what is on the online doc and ran it on AWS CodeBuild, no reason this should not work...

@SebSchwartz

Could you send us your script? this is our email amplify-cli@amazon.com
I'm puzzled by the fact that the provider plugin is actually active, and then you still get the error.

I just sent the email with the script @UnleashedMind , thanks for help ;)

@SebSchwartz running it as a globally installed package instead of just a binary in your project's node_modules

Any news on that @UnleashedMind @kaustavghosh06 ?
It's been more than one month that this issue is there and as I already said I'm not doing anything fancy, just copy/paste the doc init headless and run them inside an AWS CodeBuild...

If that helps, with new amplify version I got this at init:

aws-cli/1.16.284 Python/3.8.0 Linux/4.14.152-98.182.amzn1.x86_64 exec-env/AWS_ECS_EC2 botocore/1.13.20 
Scanning for plugins... 
The following official plugins are missing or inactive: 
    awscloudformation: provider | [email protected] 
    analytics: category | [email protected] 
    api: category | [email protected] 
    auth: category | [email protected] 
    function: category | [email protected] 
    hosting: category | [email protected] 
    interactions: category | [email protected] 
    notifications: category | [email protected] 
    predictions: category | [email protected] 
    storage: category | [email protected] 
    xr: category | [email protected] 
    codegen: util | [email protected] 
    android: frontend | [email protected] 
    ios: frontend | [email protected] 
    javascript: frontend | [email protected] 
    mock: util | [email protected] 
Plugin scan successful 

I found the "problem". It seems that installing amplify-cli with yarn globally is not ok...

I just changed to npm install -g @aws-amplify/cli --unsafe-perm=true and it worked...

I am trying to run headless on a Mac trying to build react-native and I am hitting the same issue as @SebSchwartz in that I am getting the The following official plugins are missing or inactive: error.

I have run the npm install -g @aws-amplify/cli --unsafe-perm=true command and it is still failing for me.

Is there anything else I can try that might get this working?

@nelsona Could you please try using npm install -g @aws-amplify/cli and see if you're still facing this issue?

@kaustavghosh06 Just tried this and I now get an issue with the .aws/credentials file not existing even though I have useProfile: false set in the config...

Can confirm that this is only happening when installing through yarn.
Even when manually installing the missing plugins, e.g. amplify-provider-awscloudformation, it still won't recognise them as a provider plugin.

When using npm to install, I also noticed that there is a big fat post-install message, which I hadn't seen when using yarn. Could it be that some post-install hook is failing?

@kaustavghosh06 Just tried this and I now get an issue with the .aws/credentials file not existing even though I have useProfile: false set in the config...

@kaustavghosh06 I have the same issue. Were you able to figure this out?

@sarahsga easy workaround to create those files manually:
mkdir -p ~/.aws; touch ~/.aws/credentials; touch ~/.aws/config

I received this error as well. I was able to fix the issue as suggested above by uninstalling the global yarn version, manually deleting /usr/local/bin/amplify and reinstalling using npm fixed the issue for me. Any idea when this is going to be fixed for yarn? Thanks

Was this page helpful?
0 / 5 - 0 ratings