diff --git a/.changeset/friendly-ravens-collect.md b/.changeset/friendly-ravens-collect.md new file mode 100644 index 0000000000..da1850f24e --- /dev/null +++ b/.changeset/friendly-ravens-collect.md @@ -0,0 +1,6 @@ +--- +"@pnpm/plugin-commands-setup": patch +"pnpm": patch +--- + +`pnpm setup` should remove the CLI from the target location before moving the new binary [#8173](https://github.com/pnpm/pnpm/issues/8173). diff --git a/packages/plugin-commands-setup/package.json b/packages/plugin-commands-setup/package.json index 9d83dcb786..9d7b9a542c 100644 --- a/packages/plugin-commands-setup/package.json +++ b/packages/plugin-commands-setup/package.json @@ -33,6 +33,7 @@ "@pnpm/cli-meta": "workspace:*", "@pnpm/cli-utils": "workspace:*", "@pnpm/os.env.path-extender": "catalog:", + "@zkochan/rimraf": "catalog:", "render-help": "catalog:" }, "funding": "https://opencollective.com/pnpm", diff --git a/packages/plugin-commands-setup/src/setup.ts b/packages/plugin-commands-setup/src/setup.ts index 1c647887e8..99aa07425d 100644 --- a/packages/plugin-commands-setup/src/setup.ts +++ b/packages/plugin-commands-setup/src/setup.ts @@ -9,6 +9,7 @@ import { type PathExtenderReport, } from '@pnpm/os.env.path-extender' import renderHelp from 'render-help' +import rimraf from '@zkochan/rimraf' export const rcOptionsTypes = (): Record => ({}) @@ -59,6 +60,7 @@ function copyCli (currentLocation: string, targetDir: string): void { prefix: process.cwd(), }) fs.mkdirSync(targetDir, { recursive: true }) + rimraf.sync(newExecPath) fs.copyFileSync(currentLocation, newExecPath) } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f862efd14b..03e22daaef 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3875,6 +3875,9 @@ importers: '@pnpm/os.env.path-extender': specifier: 'catalog:' version: 2.0.0 + '@zkochan/rimraf': + specifier: 'catalog:' + version: 3.0.2 render-help: specifier: 'catalog:' version: 1.0.3