amplify-cli: Hosting - Creating a nested amplify project is not supported

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

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

16.10.0

Amplify CLI Version

7.6.7

What operating system are you using?

Mac

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

no

Amplify Categories

hosting

Amplify Commands

Not applicable

Describe the bug

Since today our hosting CI/CD crashes when building the backend with the error message: Creating a nested amplify project is not supported. Project root detected: /codebuild/output/srcxxxxxxx/src/xxxxxx Because the only change from our successful build was a little bit of frontend code, we already thought that this bug cant be due to our latest change, so for testing we rolled back to the last successful build, but the error still occurs.

Any ideas?

Expected behavior

CI/CD pipeline should build it like normal

Reproduction steps

Redeploy a version in CI/CD pipeline

GraphQL schema(s)

# Put schemas below this line


Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 30 (7 by maintainers)

Most upvoted comments

I’m facing the same problems too. There seems to be a problem with the new CLI version.

We experienced the same issue in trying to set up front end hosting (Next.js) for our existing backend. We have a monorepo with the appRoot set to web in the amplify.yml file.

Downgrading Amplify CLI to 9.1.0 worked around this error for us, too 👍

Just an FYI I was running 9.2.1 and having this issue, I downgraded to my colleagues version at 9.1.0 and it worked

Hi @foobarnes, @bkmulusew can you check the path printed in the error message after Project root detected: and look for an amplify directory in that path? If exists it might be that at some point an attempt was made to initialize an amplify project in the path printed in the error message? Can you remove/rename that amplify directory and retry the amplify init command?

I had an amplify directory created by mistake at a parent root. I deleted it and worked.

Getting this problem too when running amplify init inside a blank directory

Hey folks 👋 I’ve marked this as a documentation issue to improve the Hosting docs for monorepos. From your feedback here, it has become clear that the monorepo support with the buildspec amplify.yml file is confusing in that the appRoot is where amplifyPush --simple will run, which expects an amplify/ directory in that root.

|- my-project/
|-- apps/
|--- my-react-app/
|---- amplify/
|---- package.json
|--- my-svelte-app/

Hi @lazpavel , This is happening in the backend during the “amplifyPush --simple” command. I modified my amplify,yml file to run pwd before and after the “amplifyPush --simple” script.

version: 1
applications:
    -   appRoot: apps/earthxapp
        backend:
            phases:
                build:
                    commands:
                        - pwd
                        - amplifyPush --simple
                        - pwd
        frontend:
            phases:
                preBuild:
                    commands:
                        - npm config set @gsap:registry https://npm.greensock.com/
                        - npm config set //npm.greensock.com/:_authToken=XXXXXXXXXXXX
                        - npm ci
                        - amplify pull -y
                build:
                    commands:
                        - npx nx build --prod
            artifacts:
                baseDirectory: ../../dist/apps/earthxapp
                files:
                    - '**/*'

The output in the AWS Amplify console is:

Screen Shot 2022-08-16 at 10 54 53 AM

I think “earthx/apps/earthxapp” should be correct for the Nx Monorepo setup. “aws-exports.js” gets placed in “apps/earthxapp/src” on my system.

My “amplify/.config/project-config.json” file contains:

{
  "providers": [
    "awscloudformation"
  ],
  "projectName": "earthx",
  "version": "3.1",
  "frontend": "javascript",
  "javascript": {
    "framework": "angular",
    "config": {
      "SourceDir": "apps/earthxapp/src",
      "DistributionDir": "dist/apps/earthxapp",
      "BuildCommand": "nx build --prod",
      "StartCommand": "nx serve"
    }
  }
}

Note that if I change the following Environment variable in the AWS Amplify console from (latest):

Screen Shot 2022-08-16 at 11 07 37 AM

to (9.1.0):

Screen Shot 2022-08-16 at 11 09 31 AM

Then everything compiles and deploys correctly.

Thanks for looking into this.

Hey @josefaidt,

Thank you for your help. Indeed we forgot to set the amplify build to our version and it was set to latest. After downgrading to our version it works again. Maybe this case might still be of interest to you.

BR Chris