amazon-archives / awsmobile-cli

CLI experience for Frontend developers in the JavaScript ecosystem.
Apache License 2.0
142 stars 35 forks source link

awsmobile command does not work and hangs #157

Open vu2sar opened 6 years ago

vu2sar commented 6 years ago

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.

rqton commented 6 years ago

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

Bforsyth1234 commented 5 years ago

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

carlfedak commented 5 years ago

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?

Megajin commented 5 years ago

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

tuf22191 commented 5 years ago

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?

UnleashedMind commented 5 years ago

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

david-ghikas commented 5 years ago

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

akash-saxena150 commented 5 years ago

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

Lor3nzoMartinez commented 4 years ago

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.