awsmobile-cli icon indicating copy to clipboard operation
awsmobile-cli copied to clipboard

awsmobile command does not work and hangs

Open vu2sar opened this issue 6 years ago • 9 comments

Hi,

When using awsmobile configure/pull commands the command hangs up and does not execute. This is the same case for awsmobile init command as well

capture

The entire command hangs and i am forced to exit it with Ctrl + C. I am running windows 10 and the latest version of nodejs.

P.S This occurs only on the latest version of nodejs(10.4) when i used the LTS everything was fine.

vu2sar avatar Jul 05 '18 04:07 vu2sar

Same issue with same environment (Windows 10, NodeJS 10). Downgrade on NodeJS 8.11.3 is a good workaround, thanks @vu2sar

rqton avatar Jul 06 '18 13:07 rqton

@rqton Is correct I had node 10 and downgraded to lts and it worked Thanks!

Bforsyth1234 avatar Aug 06 '18 22:08 Bforsyth1234

Downgrading is not a good workaround, that is ridiculous, there are many features we would be giving up to downgrade node. What is the latest status on this, it has been in investigation for over 1 month?

carlfedak avatar Aug 09 '18 16:08 carlfedak

After looking into the source code I am 100% positive that this issue is related to Inquirer.js in combination with NodeJS 10.x.x.

In file: lib\aws-operations\aws-config-manager.js

function setConfig(awsDetails, callback){
    if(!awsDetails){
        awsDetails = resolveAWSConfig(true)
    }
    
    let awsInfo = awsDetails.info
    let awsConfig = awsDetails.config

    inquirer.prompt([
        {
            type: 'input',
            name: 'accessKeyId',
            message: "accessKeyId: ",
            default: awsConfig.accessKeyId
        },
        {
            type: 'input',
            name: 'secretAccessKey',
            message: "secretAccessKey: ",
            default: awsConfig.secretAccessKey
        },
        {
            type: 'list',
            name: 'region',
            message: "region: ",
            choices: awsMobileRegions,
            default: awsConfig.region
        }
    ]).then(function (answers) {
        let awsConfigChanged = false
        if(answers.accessKeyId){
            let newKeyId = answers.accessKeyId.trim()
            if(awsConfig.accessKeyId != newKeyId){
                awsConfig.accessKeyId = newKeyId
                awsConfigChanged = true
            }
        }
        if(answers.secretAccessKey){
            let newKey = answers.secretAccessKey.trim()
            if( awsConfig.secretAccessKey != newKey){
                awsConfig.secretAccessKey = newKey
                awsConfigChanged = true
            }  
        }
        if(answers.region){
            let newRegion = answers.region.trim()
            if( awsConfig.region != newRegion){
                awsConfig.region = newRegion
                awsConfigChanged = true
            }  
        }
        if(awsConfigChanged){
            let jsonString = JSON.stringify(awsConfig)
            fs.writeFileSync(awsInfo.AWSConfigFilePath, jsonString, 'utf8')
            awsConfigInfoManager.setNoProfileSync(awsInfo)
        }

        if(callback){
            callback(awsDetails)
        }
    })
}

After the inquirer.prompt call, the next promise won't resolve itself. Hence it hangs up which is leading to invalid tokens.

@UnleashedMind

Megajin avatar Sep 09 '18 10:09 Megajin

Hi, this is really frustrating. For a company as large as Amazon, this should not be a problem. Has anyone looked at Megajin's analysis and developed an alternative?

tuf22191 avatar Sep 12 '18 03:09 tuf22191

Sorry to hear your frustration. But it seems like the only work around right now is to downgrade to node 8.9.x when running on Windows 10. People reported similar issues on inquirer when running on Windows 10 https://github.com/SBoudrias/Inquirer.js/issues/643 https://github.com/Shopify/slate-cli/issues/87

UnleashedMind avatar Sep 12 '18 18:09 UnleashedMind

Had the same problem. The following command which bypasses the prompts worked for me:

awsmobile configure aws $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY $AWS_DEFAULT_REGION

david-ghikas avatar Jan 31 '19 17:01 david-ghikas

Had the same problem. The following command which bypasses the prompts worked for me:

awsmobile configure aws $AWS_ACCESS_KEY_ID $AWS_SECRET_ACCESS_KEY $AWS_DEFAULT_REGION

This worked for me as well. I'm running Node 10.15

akash-saxena150 avatar Mar 21 '19 07:03 akash-saxena150

I had the same problem and nothing was really working and I ended up using the git scm bash command line and running the command and was able to configure and init the whole thing hope that helps.

Lor3nzoMartinez avatar Jul 30 '19 21:07 Lor3nzoMartinez