aws-amplify / aws-amplify/amplify-cli
Fresh Amplify Pull on a fresh Git Checkout of previously working project, now fails with 'Packaging overrides failed.'
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### How did you install the Amplify CLI?
npm install -g @aws-amplify/cli
### If applicable, what version of Node.js are you using?
v18.0.0
### Amplify CLI Version
12.3.0
### What operating system are you using?
MacOS 13.4.1 (Ventura)
### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes made.
### Describe the bug
I've had a project working since January. 35 days ago was my last deploy. I am prepping for a launch next week and need to make a few changes.
I did a fresh git checkout of the project, then ran Amplify Pull to receive an error:
````
✖ Fetching updates to backend environment: dev from the cloud.
✖ There was an error initializing your environment.
🛑 Packaging overrides failed.
Command failed with exit code 1: yarn install
Usage Error: The nearest package directory (/Users/johnmcbride/projects/amplifyapp/amplify/backend) doesn't seem to be part of the project declared in /Users/johnmcbride/projects/amplifyapp.
- If /Users/johnmcbride/projects/amplifyapp isn't intended to be a project, remove any yarn.lock and/or package.json file there.
- If /Users/johnmcbride/projects/amplifyapp is intended to be a project, it might be that you forgot to list amplify/backend in its workspace configuration.
- Finally, if /Users/johnmcbride/projects/amplifyapp is fine and you intend amplify/backend to be treated as a completely separate project (not even a workspace), create an empty yarn.lock file in it.
$ yarn install [--json] [--immutable] [--immutable-cache] [--check-cache] [--inline-builds] [--mode #0]
Resolution: There may be errors in your overrides file. If so, fix the errors and try again.
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
Session Identifier: 8782b01f-9fb0-4af1-a030-7f21f4dec018
````
I don't particularly understand this error message.
My overrides is one which has been working for months:
amplify/backend/api/enrolmentmanager/override.ts
````// This file is used to override the REST API resources configuration
import { AmplifyApiRestResourceStackTemplate } from "@aws-amplify/cli-extensibility-helper";
export function override(resources: AmplifyApiRestResourceStackTemplate) {
// Replace the following with your Auth resource name
const authResourceName = "amplifyapp0cb91442";
const userPoolArnParameter = "AuthCognitoUserPoolArn";
// Add a parameter to your Cloud Formation Template for the User Pool's ID
resources.addCfnParameter(
{
type: "String",
description:
"The ARN of an existing Cognito User Pool to authorize requests",
default: "NONE",
},
userPoolArnParameter,
{ "Fn::GetAtt": [`auth${authResourceName}`, "Outputs.UserPoolArn"] }
);
// Create the authorizer using the AuthCognitoUserPoolArn parameter defined above
resources.restApi.addPropertyOverride("Body.securityDefinitions", {
Cognito: {
type: "apiKey",
name: "Authorization",
in: "header",
"x-amazon-apigateway-authtype": "cognito_user_pools",
"x-amazon-apigateway-authorizer": {
type: "cognito_user_pools",
providerARNs: [
{
"Fn::Join": ["", [{ Ref: userPoolArnParameter }]],
},
],
},
},
});
// For every path in your REST API
for (const path in resources.restApi.body.paths) {
// Add the Authorization header as a parameter to requests
resources.restApi.addPropertyOverride(
`Body.paths.${path}.x-amazon-apigateway-any-method.parameters`,
[
...resources.restApi.body.paths[path]["x-amazon-apigateway-any-method"]
.parameters,
{
name: "Authorization",
in: "header",
required: false,
type: "string",
},
]
);
// Use your new Cognito User Pool authorizer for security
resources.restApi.addPropertyOverride(
`Body.paths.${path}.x-amazon-apigateway-any-method.security`,
[{ Cognito: [] }]
);
}
}
````
A yarn.lock file is already present in amplify/backend, so don't know what it's complaining about (attached as yarn.lock.txt, because .lock files not upload able by GitHub)
I don't know where to begin.
[yarn.lock.txt](https://github.com/aws-amplify/amplify-cli/files/12496771/yarn.lock.txt)
### Expected behavior
Amplify pull should work and I should be able to make changes and then push.
### Reproduction steps
1. Git checkout project
2. Amplify pull
3. Errors
### Project Identifier
amplify diagnose fails with:
Learn more at https://docs.amplify.aws/cli/reference/diagnose/
✅ Report saved: /var/folders/q1/1x9cp1n17p11gktfwq9qf50r0000gn/T/amplifyapp/report-1693562487418.zip
⠋ Sending zip
File at path: '/Users/johnmcbride/projects/amplifyapp/amplify/backend/amplify-meta.json' does not exist
✖ Sending zip
My app id is d1unq6d9vt4zkd.
### 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
Assessment
This issue has not been assessed yet.