Fresh Amplify Pull on a fresh Git Checkout of previously working project, now fails with 'Packaging overrides failed.'
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
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.
Expected behavior
Amplify pull should work and I should be able to make changes and then push.
Reproduction steps
- Git checkout project
- Amplify pull
- 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.
Note, to try and overcome and problems in my dev branch, which is the most fluid, I checked out the pilot branch and env pulled my pilot env. These branches and envs are 'gold standard', nothing has changed there in weeks and exactly the same error.
❯ which yarn
/Users/johnmcbride/.nvm/versions/node/v18.0.0/bin/yarn
❯ yarn --version
3.5.1
Could it be my version of yarn? I saw someone else had challenges with that. I recently did a complete reinstall of brew - is that it maybe?
interestingly yarn.lock is in the git repo, but is gone after Amplify Pull....
omg. fixed after deleting yarn 3 and installing yarn v1.
IS this a thing?
I deserve a chocolate bar after that. Heart attack over. Leaving this open though - maybe some more useful messaging about supported yarn versions or yarn version mismatches would prevent others suffering from mild coronaries.
@johnemcbride thank you for reaching out. I was able to reproduce the issue. Marking this as investigating to dive deeper into the behaviour. Will provide an update as soon as i get any additional information.
Marking this a feature request for improved error messaging when using yarn versions that are not supported.
I'm using Amplify backend within a NextJS front-end and have switched package manager to yarn for the front-end (yarn v4.2.2 to be precise). As per above the yarn.lock file is removed whenever I run amplify pull and it fails with the above error. At this point, with numerous other niggles, I'm binning Amplify - just not fit for purpose I'm afraid.
The year is 2025, and this is still a problem that's biting people, including us.
Marking this a feature request for improved error messaging when using yarn versions that are not supported.
@ykethan
Can you please do that. Error messages are really not helpful in the cli.
Also where can I find the supported yarn versions?