Skip to content

cache clear does not remove lastKnownGood.json from cache #675

Open
@MikeMcC399

Description

@MikeMcC399

Current behavior

corepack cache clear does not fully clear the Corepack cache. It leaves behind lastKnownGood.json, removing only the install folder v1 from the Corepack cache.

Expected behavior

The README document says;

corepack cache clean

Clears the local COREPACK_HOME cache directory.

COREPACK_HOME can be set in order to define where Corepack should install the package managers. By default it is set to %LOCALAPPDATA%\node\corepack on Windows, and to $HOME/.cache/node/corepack everywhere else.

so the expectation is that after executing corepack cache clear on Linux, there will be no files left in the $HOME/.cache/node/corepack directory.

Alternatively, if it is intentional to not delete the lastKnownGood.json file from the Corepack cache, then the documentation should be changed.

Steps to reproduce

Ubuntu 24.04.2 LTS, Node.js 22.14.0 LTS, Corepack 0.32.0

rm -rf ~/.cache/node/corepack
npm install corepack@latest -g
corepack install -g yarn@latest
corepack cache clear
find ~/.cache/node/corepack

Logs

Installing yarn@4.7.0...
/home/mike/.cache/node/corepack
/home/mike/.cache/node/corepack/lastKnownGood.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions