{"record":{"id":"e3631450742b24a6","repo":"pulumi/pulumi","slug":"yarn-pack-completed-successfully-but-the-packed","errorCode":null,"errorMessage":"'yarn pack' completed successfully but the packed .tgz file was not generated: %w","messagePattern":"'yarn pack' completed successfully but the packed \\.tgz file was not generated: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/nodejs/npm/yarn.go","lineNumber":189,"sourceCode":"\tpackfile := tmpfile.Name()\n\t// Clean up the tarball after we're done here.\n\tdefer func() {\n\t\tcontract.IgnoreClose(tmpfile)\n\t\tcontract.IgnoreError(os.Remove(packfile))\n\t}()\n\n\tcommand := exec.CommandContext(ctx, yarn.executable, \"pack\", \"--filename\", packfile)\n\tcommand.Dir = dir\n\n\terr = yarn.runCmd(command, stderr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Read the tarball in as a byte slice.\n\ttarball, err := os.ReadFile(packfile)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"'yarn pack' completed successfully but the packed .tgz file was not generated: %w\", err)\n\t}\n\n\treturn tarball, nil\n}\n\n// checkYarnLock checks if there's a file named yarn.lock in pwd.\n// This function is used to indicate whether to prefer Yarn over\n// other package managers.\nfunc checkYarnLock(pwd string) bool {\n\t_, err := fsutil.Searchup(pwd, \"yarn.lock\")\n\treturn err == nil\n}\n","sourceCodeStart":171,"sourceCodeEnd":202,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/nodejs/npm/yarn.go#L171-L202","documentation":"'yarn pack' exited successfully but reading the produced .tgz from disk with os.ReadFile failed. Like the pnpm equivalent, this means the tarball path the SDK derived from yarn's output does not exist at the expected location.","triggerScenarios":"Calling the yarn pack flow when the parsed pack output filename doesn't resolve to a real file — yarn printed a relative path from a different cwd, or yarn version output format differs from what's parsed.","commonSituations":"Yarn Berry (v2+) vs Classic output differences; custom yarn config (e.g. enableGlobalCache or pack destination) moving the tarball; extra log lines shifting the parsed filename.","solutions":["Run 'yarn pack' manually in the project directory and confirm where the tgz lands","Use Yarn Classic (v1) whose pack output format matches the SDK's expectations","Remove custom yarn pack destination settings from .yarnrc.yml/.yarnrc","Check for plugins/scripts printing extra output that corrupts filename parsing"],"exampleFix":"// before (.yarnrc.yml)\n# custom pack config altering output location\n// after\n# removed; tgz generated in project root as expected","handlingStrategy":"validation","validationCode":"import fs from 'fs';\nif (!fs.existsSync(path.join(dir, 'package.tgz'))) {\n  throw new Error('yarn pack tarball not found in ' + dir);\n}","typeGuard":null,"tryCatchPattern":"try { await packYarn(dir) } catch (err) { if (String(err).includes('.tgz file was not generated')) { console.error('Run yarn pack manually to see where the tarball lands'); } throw err; }","preventionTips":["Use Yarn Classic (v1) for projects packed by the SDK","Do not configure custom pack destinations in .yarnrc/.yarnrc.yml","Silence plugins/scripts that add extra stdout lines around yarn pack","Verify the tgz location once locally per CI image"],"tags":["yarn","packaging","file-not-found"],"backgroundTag":"pack-tarball-missing","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}