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

Add support for cleaning cache for a specific package: dart pub cache clean <package> #4460

Open
Pingear opened this issue Dec 8, 2024 · 1 comment
Labels
type-enhancement A request for a change that isn't a bug

Comments

@Pingear
Copy link

Pingear commented Dec 8, 2024

Currently, the dart pub cache clean command removes all cached packages, which can be inconvenient when a developer only needs to refresh the cache for a single package. This is particularly relevant when working with Git dependencies, as changes to a Git-based package do not trigger automatic updates unless the version or commit reference changes.

Feature Request:

Introduce a feature in the dart pub cache command to allow developers to clean the cache for a specific package without affecting the entire cache. The proposed syntax could be:

dart pub cache clean <package-name>

Benefits:

  1. Selective Cache Management: Developers can target specific packages for cache cleaning without affecting other dependencies.
  2. Improved Developer Experience: Reduces unnecessary re-downloading of unaffected packages, saving time and bandwidth.
  3. Consistency with Modern Tools: Many package managers (e.g., npm, pip) support selective cache cleaning for specific packages.

Use Case:

For example, when a Git dependency (my_package) is updated in the remote repository but retains the same version in pubspec.yaml, developers currently need to either:

  1. Manually delete the cached package from the filesystem.
  2. Clear the entire cache, which forces unnecessary downloads.

With this feature, developers could simply run:

dart pub cache clean my_package
dart pub get

This enhancement would streamline workflows for projects using Git dependencies or frequently updated packages.

@Pingear Pingear changed the title **Add support for cleaning cache for a specific package: dart pub cache clean <package>** Add support for cleaning cache for a specific package: dart pub cache clean <package> Dec 8, 2024
@sigurdm
Copy link
Contributor

sigurdm commented Dec 9, 2024

Yeah - I this is a good idea.

We could have two variants, something like:

dart pub cache clean --current-project

Which removes all packages depended on by the current project (the current package_config.json).

and

dart pub cache remove <package>

Which removes a single package from the cache.

For the second one we probably need a way to also remove git packages, and a way to remove from specific hosts.

@sigurdm sigurdm added the type-enhancement A request for a change that isn't a bug label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants