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

Cannot add auth - command not found

Open ericathegreat opened this issue 8 years ago • 27 comments

Do you want to request a feature or report a bug? Bug

What is the current behavior? Attempting to run amplify auth add returns a "Command not found" error, with the suggestion: amplify auth <subcommands> add [......]

Attempting to run amplify add auth (inverting 'auth' and 'add') produces the same outcome

On the off chance, I also tried amplify add authentication, but this triggered the analytics flow. Analytics seems to be the default? (Running amplify add anything also triggered the analytics flow).

Taking a brief look at the code, it looks like Auth is structured very differently to the other modules. There is no "auth/add.js" file in the commands folder, but rather, the add command is listed in the index.js two levels up. (The index.js also looks substantially different to other commands). It seems like maybe it got missed in a code restructure?

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

See above.

What is the expected behavior?

Running amplify auth add should start the wizard process to create a cognito user store.

Which versions of Amplify CLI, and which OS are affected by this issue? Did this work in previous versions?

Amplify version: 0.1.14 (This is the first version I have used, but I assume this worked previously) Node version: 8.11.4 NPM version: 5.6.0 OS: Windows 10 (Powershell)

ericathegreat avatar Aug 27 '18 01:08 ericathegreat

Hey Erica, Were you able to get amplify configure and amplify init to work on your windows machine?

kaustavghosh06 avatar Aug 27 '18 01:08 kaustavghosh06

Hi Kaustav,

Yes. init and configure worked fine (although it didn't pick up my .aws/ config files. I was able to copy/paste the data in where required). amplify add hosting and amplify publish also worked without issue.

ericathegreat avatar Aug 27 '18 01:08 ericathegreat

Ah! Okay. Are you using windows Linux susbsystem and using the commands there? You might want to give amplify auth enable command a try and let me know if that works.

kaustavghosh06 avatar Aug 27 '18 01:08 kaustavghosh06

Re Linux Subsystem: I don't think so, although it has been a dev machine for some time so it's not completely out of the question that I turned it on at some point.

auth enable seems to have done the trick. Thank you! :)

ericathegreat avatar Aug 27 '18 01:08 ericathegreat

I may have spoken too soon - It has created the cloudformation scripts and properties, but amplify push does not seem to recognize them. No changed resources, and after running it, there is no userpool in my profile.

ericathegreat avatar Aug 27 '18 01:08 ericathegreat

Hey Erica, what does ‘amplify status’ return?

kaustavghosh06 avatar Aug 27 '18 01:08 kaustavghosh06

Category Resource name Operation Provider plugin
Auth amplifytestcognito Create awscloudformation
Hosting S3AndCloudFront No Change awscloudformation

ericathegreat avatar Aug 27 '18 01:08 ericathegreat

amplify push

Category Resource name Operation Provider plugin

? Are you sure you want to continue? true

  • Updating resources in the cloud. This may take a few minutes... √ All resources are updated in the cloud

ericathegreat avatar Aug 27 '18 01:08 ericathegreat

Okay. So the auth resource has been created locally. What happens when you do an ‘amplify push’? It should ideally create the CloudFormation stack and provision the auth resources.

kaustavghosh06 avatar Aug 27 '18 01:08 kaustavghosh06

See above ^^ (I beat you by ~1 minute)

ericathegreat avatar Aug 27 '18 01:08 ericathegreat

Hey Erica, we’re seeing some anomalous behavior on windows due to the filesystem. We’ll be figuring out a solution in the next couple of days and get back to you.

kaustavghosh06 avatar Aug 27 '18 02:08 kaustavghosh06

Hey guys, so I tried using the CLI with the Windows Linux subsystem(WSL) on windows and it works great. We have updated our main README as well with the following. Highly encourage using the WSL for your Amplify development.


If you're using Windows, the CLI currently supports [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10).

In the meanwhile, we're trying to figure out the root cause of the erroneous behavior of the CLI with the windows filesystem.

kaustavghosh06 avatar Aug 27 '18 23:08 kaustavghosh06

Thanks Kaustav. Could you point me to the part of the code which is generating the list of candidates in amplify push? I can try a few things on my local machine this evening.

ericathegreat avatar Aug 27 '18 23:08 ericathegreat

Sure, here you go - https://github.com/aws-amplify/amplify-cli/blob/master/packages/amplify-cli/src/extensions/amplify-helpers/resource-status.js

kaustavghosh06 avatar Aug 27 '18 23:08 kaustavghosh06

I have a quick workaround, but not a proper solution.

Based on my quick look, I don't think this is a filesystem issue, rather a bug in gluegun.

When I run amplify push, it should be hitting the src\commands\push.js command object. According to the gluegun docs, plugins in src directory should be taking priority. For some reason though, it's got its load order confused and is instead running the amplify-category-function\commands\push.js. (They both have "name: 'push'".) The end result is that it ignores the auth elements in its status check, because the category doesn't match. ('auth' !== 'function')

The workaround for me is to add alias: pushall to the command in src\commands\push.js, and then running amplify pushall. Because that alias is unique across the codebase it doesn't have naming conflicts and runs the correct code.

And the good news is, it looks to be creating the cognito resources. Yay!

ericathegreat avatar Aug 28 '18 05:08 ericathegreat

Hey Erica, awesome work figuring out the root cause :D. I’ve gone through Glueguns codebase and in many places they’ve considered filepaths to be of format (Unix format) dir1/dir2/dir3 instead of considering dir\dir2\dir2 format which is the windows filesystem formst which is causing erroneous behavior of the CLI in windows natively. For what it’s worth I’ve filed an issue with Gluegun a few weeks back - https://github.com/infinitered/gluegun/issues/384 and hopefully we’ll have a solution for it soon. In the meanwhile checkout @mwarger post of using wsl in native windows power shell out here - https://github.com/aws-amplify/amplify-cli/issues/13. I think it’s a great workaround.

kaustavghosh06 avatar Aug 28 '18 06:08 kaustavghosh06

@ericathegreat @kaustavghosh06 This reminds me of the weird behavior I saw in the log I posted to #13 - at Command.run (C:\dev\amplify-cli\packages\amplify-category-hosting\commands\hosting\configure.js:7:39)

That is the 5th line of the stacktrace. It's trying to grab configure from the hosting plugin - does that sound right? Seems like that could be part of the cause.

EDIT: It appears that I was able to get configure to run by aliasing it to configureamplify. I still received another error after that, but I think this still confirms @ericathegreat's findings.

mwarger avatar Aug 28 '18 12:08 mwarger

@mwarger Yes, that looks like the same underlying issue.

ericathegreat avatar Aug 28 '18 22:08 ericathegreat

The original issue, which is amplify auth add not working, is still not fixed. Using amplify auth enable as a workaround is working but does not match the documentation.

kavengagne avatar Sep 03 '18 00:09 kavengagne

@kavengagne. Are you running the CLI on windows? If yes, are you using the windows Linux subsystem as recommended in the main Readme?

kaustavghosh06 avatar Sep 03 '18 00:09 kaustavghosh06