{"record":{"id":"85c70dbf4761ff87","repo":"Budibase/budibase","slug":"please-run-in-a-plugin-directory-must-contain-pa","errorCode":null,"errorMessage":"Please run in a plugin directory - must contain package.json","messagePattern":"Please run in a plugin directory - must contain package\\.json","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/plugins/index.ts","lineNumber":52,"sourceCode":"      continue\n    }\n    try {\n      fs.unlinkSync(p)\n      deleted.push(p)\n    } catch (err: any) {\n      failed.push({\n        path: p,\n        error: err instanceof Error ? err.message : String(err),\n      })\n    }\n  }\n\n  return { deleted, failed }\n}\n\nfunction checkInPlugin() {\n  if (!fs.existsSync(\"package.json\")) {\n    throw new Error(\n      \"Please run in a plugin directory - must contain package.json\"\n    )\n  }\n  if (!fs.existsSync(\"schema.json\")) {\n    throw new Error(\n      \"Please run in a plugin directory - must contain schema.json\"\n    )\n  }\n}\n\nasync function askAboutTopLevel(name: string) {\n  const files = fs.readdirSync(process.cwd())\n  // we are in an empty git repo, don't ask\n  if (files.find(file => file === \".git\")) {\n    return false\n  } else {\n    console.log(\n      info(`By default the plugin will be created in the directory \"${name}\"`)","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/cli/src/plugins/index.ts#L34-L70","documentation":"checkInPlugin is a guard used by the Budibase CLI plugin commands (verify, migrateSvelte5). It insists the current working directory is a plugin project by checking that package.json exists. If not, it throws so the command cannot run against an unrelated directory.","triggerScenarios":"Running `budibase-plugins verify` or `budibase-plugins migrateSvelte5` from a directory where fs.existsSync(\"package.json\") is false — i.e. not at the root of a plugin project.","commonSituations":"Running the CLI from the repo root or home directory instead of the plugin folder; running inside a subdirectory of the plugin (e.g. src/) that has no package.json; a plugin scaffolded before package.json was created; a typo'd cd.","solutions":["cd into the plugin's root directory (the one containing package.json and schema.json) and re-run the command","If the directory is not yet a plugin, scaffold one with the plugin init command so package.json is generated","Run `ls package.json` to confirm your working directory before invoking the CLI"],"exampleFix":"// before (wrong dir)\n~/projects $ budibase-plugins verify\n// Error: Please run in a plugin directory - must contain package.json\n// after\ncd ~/projects/my-budi-plugin && budibase-plugins verify","handlingStrategy":"validation","validationCode":"import fs from \"fs\"\nif (!fs.existsSync(\"package.json\")) {\n  throw new Error(\"Not a plugin directory: package.json missing. Run from the plugin root.\")\n}","typeGuard":"const isPluginDir = (dir: string = process.cwd()): boolean =>\n  fs.existsSync(`${dir}/package.json`) && fs.existsSync(`${dir}/schema.json`)","tryCatchPattern":null,"preventionTips":["Always run plugin CLI commands from the directory containing both package.json and schema.json","Add a shell alias/script that cds to the plugin root before invoking the CLI","Check `pwd` and `ls package.json schema.json` if a command fails"],"tags":["cli","filesystem","plugin","working-directory"],"backgroundTag":"missing-plugin-manifest","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}