Skip to content

When using an offline cache, yarn upgrade adds the new package to the cache but does not remove the old one #2109

@rmacklin

Description

@rmacklin

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

If you're using an in-repo offline cache (https://yarnpkg.com/blog/2016/11/24/offline-mirror), when you run yarn upgrade <package>, the new version of <package> will be added to the offline cache, but the old version won't be removed (even if it is not used by any other packages). It should be removed, so that manual deletion is not required to prevent the cache from growing to contain many unused packages over time.

If the current behavior is a bug, please provide the steps to reproduce.

Reproduction repository: https://github.com/rmacklin/yarn-issue-2109-repro

Steps to reproduce:

  1. git clone git@github.com:rmacklin/yarn-issue-2109-repro.git
  2. cd yarn-issue-2109-repro
  3. node yarn-0.17.10.js upgrade left-pad
  4. Observe:

This added a new, untracked tarball for the new version of left-pad in the
cache:

On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   package.json
	modified:   yarn.lock

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	npm-packages-offline-cache/left-pad-1.1.3.tgz

no changes added to commit (use "git add" and/or "git commit -a")

However, the old npm-packages-offline-cache/left-pad-1.1.2.tgz tarball was not removed even though it's no longer used. This means that it has to be manually deleted (an easy step to forget) in order to prevent the offline cache from growing to contain many unused packages over time.

What is the expected behavior?

The old, unused tarball should be removed, so that people don't have to remember to remove it from the repo. It would be fine if this behavior is behind an option or a .yarnrc setting.

Please mention your node.js, yarn and operating system version.

Node v6.2.0, yarn v0.17.10, Mac OSX 10.9.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions