Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm install -g cdk-assets@latest fails with TAR_BAD_ARCHIVE: Unrecognized archive format error #252

Closed
ugur-koc opened this issue Dec 16, 2024 · 3 comments

Comments

@ugur-koc
Copy link

AWS CDK CodePipeline fails in the image building step with the following error:

[Container] 2024/12/16 18:58:32.895160 Running command npm install -g cdk-assets@latest
--
npm warn tar TAR_BAD_ARCHIVE: Unrecognized archive format
npm error code TAR_BAD_ARCHIVE
npm error TAR_BAD_ARCHIVE: Unrecognized archive format`

Here is the build spec used by the AWS CodeBuild
`{
  "phases": {
    "build": {
      "commands": [
        "cdk-assets --path \"assembly-REDACTED.assets.json\" --verbose publish \"REDACTED\""
       ]
    },
    "install": {
      "commands": [
        "npm install -g cdk-assets@latest"
      ]
    }
  },
  "version": 0.2
}

Note that this build spec is generated by the CDK SDK CodePipeline construct.

We started observing this failure at Dec 16, 2024 11:55 AM (UTC-5:00).

On Dec 16, 2024 9:00 AM (UTC-5:00), there was a successfully run of the this code build step --which suggests something might have changed in between 9:00 AM and 11:55 AM the same day.

I've tried installing previous version of the cdk-assets package but the problem persisted.

I've also tried updating npm prior to installing cdk-assets but the problem persisted


[Container] 2024/12/16 18:51:56.122264 Entering phase INSTALL
--
21 | [Container] 2024/12/16 18:51:56.449075 Running command npm update -g npm
22 | npm warn EBADENGINE Unsupported engine {
23 | npm warn EBADENGINE   package: '[email protected]',
24 | npm warn EBADENGINE   required: { node: '^20.17.0 \|\| >=22.9.0' },
25 | npm warn EBADENGINE   current: { node: 'v18.20.3', npm: '10.7.0' }
26 | npm warn EBADENGINE }
27 |  
28 | removed 15 packages, and changed 103 packages in 17s
29 |  
30 | 40 packages are looking for funding
31 | run `npm fund` for details
32 |  
33 | [Container] 2024/12/16 18:52:17.181419 Running command npm install -g cdk-assets@latest
34 | npm warn cli npm v11.0.0 does not support Node.js v18.20.3. This version of npm supports the following node versions: `^20.17.0 \|\| >=22.9.0`. You can find the latest version at https://nodejs.org/.
35 | npm warn tar TAR_BAD_ARCHIVE: Unrecognized archive format
36 | npm error code TAR_BAD_ARCHIVE
37 | npm error TAR_BAD_ARCHIVE: Unrecognized archive format
38 | npm error A complete log of this run can be found in: /root/.npm/_logs/2024-12-16T18_52_17_253Z-debug-0.log
39 |  
40 | [Container] 2024/12/16 18:52:21.992733 Command did not exit successfully npm install -g cdk-assets@latest exit status 1
41 | [Container] 2024/12/16 18:52:22.342031 Phase complete: INSTALL State: FAILED
42 | [Container] 2024/12/16 18:52:22.342050 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm install -g cdk-assets@latest. Reason: exit status 1

This is the environment spec

"Environment": {
     "ComputeType": "BUILD_GENERAL1_SMALL",
     "Image": "aws/codebuild/standard:7.0",
     "ImagePullCredentialsType": "CODEBUILD",
     "PrivilegedMode": false,
     "Type": "LINUX_CONTAINER"
    },

[which is also auto-generated by CDK].

@ailanthuz-ai
Copy link

Facing the same issue. Were you able to solve it?

@ailanthuz-ai
Copy link

ailanthuz-ai commented Dec 17, 2024

Found a fix to this. Adding to buildspec.yml worked

{
  "phases": {
    "install": {
      "commands": [
        "npm config set registry https://registry.npmmirror.com/ --global",
        "npm cache clean --force",
        "npm install -g cdk-assets@latest"
      ]
    },
  }
}

Here's the thread where I found it

@ugur-koc
Copy link
Author

Thank you for the quick solution and pointer @ailanthuz-ai ! It worked for me too.

I will close this issue as the problem seems to be with npm itself --not with the cdk-assets package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants