aws-amplify / aws-amplify/amplify-cli

Unable to push or pull because packaging API overrides fails

Open
#14,232 6 comments 0 reactions 0 assignees View on GitHub
not-reproducible pending-response question
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 -g i @aws-amplify/cli

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

v20.18.1

### Amplify CLI Version

13.0.1

### What operating system are you using?

MacOS

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

Added `override.ts` file.

It's likely outside the scope of this ticket, but this was used to customize datasource for some GraphQL DynamoDB mutations to use `transactWriteItem` to ensure non-duplicate email addresses on user records (as the email address isn't the main record's primary key so we used `transactWriteItem` to also write to a "unique ids" separate table where the email address written there is that table's PK).

### Describe the bug

I just upgraded `amplify-cli` from `12.14.1` to `13.0.1` and since that upgrade I'm getting the following error:

```
🛑 Packaging overrides failed.
Command failed with exit code 1: yarn tsc --project xxx/amplify/backend/api/yyy/build/tsconfig.resource.json
error Command "tsc" not found.
yarn run v1.22.19
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```

I've tracked it down to changes made in aws-amplify/amplify-cli#14093. In particular [this change](https://github.com/aws-amplify/amplify-cli/pull/14093/files/f28c6467392195aeaba5b3052c97baa93fcbfe0e#diff-1e3002b62510630544a91276ba158d7ea290ddf854edbeb32b8e8e18da31799b) to `override-skeleton-generator.ts`.

This could be an issue on our side but the change that PR introduces to that file will work for us if we change the `cwd` argument on [the line below](https://github.com/aws-amplify/amplify-cli/blob/72db54eb3be8d2aea30215fbae8819a20b7d76ed/packages/amplify-cli-core/src/overrides-manager/override-skeleton-generator.ts#L97):

```diff
- cwd: tsConfigDir,
+ cwd: cwd,
```

I'm unclear how it's working for everyone else with `cwd` set to `tsConfigDir` since the overrides' `package.json` is installed just above this using `cwd` as the current working directory:

```ts
execa.sync(packageManager.executable, ['install'], {
cwd,
stdio: 'pipe',
encoding: 'utf-8',
});
```

So the `node_modules` is under `cwd` and not `tsConfigDir`. Using `tsConfigDir` results in `yarn` not being able to find `tsc` after this PR.

I don't understand this code enough to definitely know it's an issue on our end, which is why I created this ticket, even though it may be down to some customization or old version of our application since it was created several years ago, so any insight would be really appreciated.

I'm surprised this is working for everyone else but we do have a few customizations in our code base (hence the `override.ts` file).

Adding to my confusion is that the `tsconfig.ts` that's in `cwd` not `tsConfigDir` contains:

```json
"outDir": "build"
```

So that also makes me expect `tsc` to be run from `cwd` and output to the `tsConfigDir` (which is set to a `build` sub-directory). But again I'm fairly confused, so I could be completely misunderstanding this.

### Expected behavior

`amplify push` should build API overrides resource successfully before deploying.

### Reproduction steps

1. Create an API `override.ts` file by running `amplify override api`
2. Run `amplify push`

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

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.