aws-amplify / aws-amplify/amplify-cli

receiving vague error and stack trace running `amplify build` in an uninitialized project

Open
#11,712 1 comment 0 reactions 0 assignees View on GitHub
bug ops-errors ops-general p2 platform
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### How did you install the Amplify CLI?

pnpm

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

18

### Amplify CLI Version

10.6.0

### 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.

n/a

### Describe the bug

Running `amplify build` in an uninitialized project causes vague error and stack trace looking for `amplify-meta.json`

```
➜ amplify build
🛑 Error: File at path: '/Users/josef/Documents/projects/aws-amplify/tmp/docs/amplify/backend/amplify-meta.json' does not exist
at Function.readJson (/snapshot/repo/build/node_modules/amplify-cli-core/lib/jsonUtilities.js:40:19)
at StateManager.getData (/snapshot/repo/build/node_modules/amplify-cli-core/lib/state-manager/stateManager.js:323:56)
at StateManager.getMeta (/snapshot/repo/build/node_modules/amplify-cli-core/lib/state-manager/stateManager.js:42:25)
at getAllResources (/snapshot/repo/build/node_modules/@aws-amplify/amplify-category-custom/lib/utils/dependency-management-utils.js:88:50)
at generateDependentResourcesType (/snapshot/repo/build/node_modules/@aws-amplify/amplify-category-custom/lib/utils/build-custom-resources.js:60:198)
at Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/commands/build.js:14:76)
at Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:179:29)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:142:5)
at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:40:9)
at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:119:5)
🛑 There was an error building the resource
```

### Expected behavior

CLI should print a helpful message

```
We've detected an Amplify project but it does not appear to be initialized. Run `amplify init` to get started
```

### Reproduction steps

1. clone some Amplify project
2. run `amplify build`
3. observe error

### Project Identifier

_No response_

### Log output

```
# Put your logs below this line

```

### Additional information

_No response_

### Before submitting, please confirm:

- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue by cloning an Amplify project and running `amplify build` before initialization. Start with the build command entry point shown in `@aws-amplify/cli-internal/lib/commands/build.js` and the `amplify-meta.json` lookup in `amplify-category-custom`; done means an uninitialized project receives the helpful `amplify init` guidance described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.