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

Removing outdated boxes #4412

Closed
chrisvire opened this issue Aug 29, 2014 · 31 comments
Closed

Removing outdated boxes #4412

chrisvire opened this issue Aug 29, 2014 · 31 comments

Comments

@chrisvire
Copy link
Contributor

@chrisvire chrisvire commented Aug 29, 2014

I can run "vagrant box outdated" to see the list of boxes that need to be updated.
I can run "vagrant box update" that will update these boxes.
I really want to have an easy way to remove the now outdated boxes.

@chrisvire
Copy link
Contributor Author

@chrisvire chrisvire commented Aug 29, 2014

I would be fine with scripting this if I knew how to take the output of one vagrant command and feed it into another...

@chrisvire
Copy link
Contributor Author

@chrisvire chrisvire commented Nov 8, 2014

If Implement this feature, how would you prefer that it be accessed from the command-line?

Here are some options I thought about:

vagrant box update --remove-outdated [provider]
vagrant box remove --outdated [provider]

Suggestions?

chrisvire added a commit to chrisvire/vagrant-sil that referenced this issue Nov 10, 2014
vagrant doesn't have a way to clean up outdated boxes.  I have an
open issue (hashicorp/vagrant#4412).
I will likely implement it once I get feedback from the maintainer
as to how he would want it exposed in the command-line UI.
@dbazhal
Copy link

@dbazhal dbazhal commented Jun 30, 2015

Plusing this request. I think "remove --outdated" could be enough.

@everflux
Copy link

@everflux everflux commented Aug 20, 2015

Can you just create a pull request for your proposal?

@thom8
Copy link

@thom8 thom8 commented Nov 25, 2015

👍

@chrisvire This would be an awesome addition!

In the meantime you can use this command -->

curl -LSs http://bit.ly/box-update-all | bash

which will update all your base boxes and remove all old versions.

@kylegibson
Copy link

@kylegibson kylegibson commented Jan 6, 2016

Has anyone started on this implementation?

@bbrala
Copy link
Contributor

@bbrala bbrala commented Jan 12, 2016

This feature would help me a lot so i decided to give it a go. I pretty much have it working, and will make a pull request soon hopefully.

I ended up doing a command since putting i tinto the other commands felt weird. It seemed they differ quite a lot in scope or purpose.

vagrant box remove-old-versions --provider docker

I probably use the internal action to remove the boxes so it is less new code. So i might also add some more options like confirming.

@bbrala
Copy link
Contributor

@bbrala bbrala commented Jan 12, 2016

Well i made a pull request #6863. I might also extract this to a seperate plugin so the feature can be used while we wait what is said about the pull request.

@bbrala
Copy link
Contributor

@bbrala bbrala commented Jan 13, 2016

Ok, i've also created a plugin with this feature. Ready to install to your local vagrant :)

https://github.com/swisnl/vagrant-remove-old-box-versions

@kylegibson
Copy link

@kylegibson kylegibson commented Jan 13, 2016

@bbrala - That is amazing! Thank you for your efforts, you've saved me several days of work!

@dbazhal
Copy link

@dbazhal dbazhal commented Jan 13, 2016

@bbrala Well done. Waiting for merge.

@amontalban
Copy link
Contributor

@amontalban amontalban commented Feb 12, 2016

+1

@bbrala great work! I have installed your plugin and works like a charm. Thanks!

@vinceskahan
Copy link

@vinceskahan vinceskahan commented Mar 9, 2016

@bbrala - this is excellent - your PR should definitely be merged - works great (vagrant 1.7.4)

@bbrala
Copy link
Contributor

@bbrala bbrala commented Mar 16, 2016

Added tests for all options except --force. And i added the options --dry-run and --name which were contributed to the plugin. Think everything should be ready for a merge.

@bbrala
Copy link
Contributor

@bbrala bbrala commented Mar 17, 2016

Ping @sethvargo

@bbrala
Copy link
Contributor

@bbrala bbrala commented Apr 12, 2016

@sethvargo is there any timeline on which this might be merged or at least reviewed?

@vinceskahan
Copy link

@vinceskahan vinceskahan commented Apr 23, 2016

The docs are correct versus the current feature set.

The request is to add a feature (integrating Bjorn's excellent plugin) so
it's in the base vagrant product without 'needing' to add a plugin. That
would require a docs update to match of course.

On Fri, Apr 22, 2016 at 11:52 PM, Joandi Leonardus <notifications@github.com

wrote:

is there any question to this documentation?

PRUNING OLD VERSIONS

Vagrant does not automatically prune old versions because it does not
know if they might be in use by other Vagrant environments.
Because
boxes can be large, you may want to actively prune them once in awhile
using vagrant box remove. You can see all the boxes that are installed
using vagrant box list.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#4412 (comment)

----- vinceskahan@gmail.com ----

@GhostLyrics
Copy link

@GhostLyrics GhostLyrics commented Jul 13, 2016

Is there any update on this?

@bbrala
Copy link
Contributor

@bbrala bbrala commented Jul 27, 2016

The PR has been tagged 2.0.0 recently, this means it will take a while before it might be merged. For now, i'd advise you to use the plugin i made, which is literally the same functionality as the PR i made for this issue.

https://github.com/swisnl/vagrant-remove-old-box-versions

@chrisroberts chrisroberts added this to the 2.0.0 milestone Sep 30, 2016
@chrisroberts chrisroberts modified the milestones: 1.10, 1.9.0 Oct 26, 2016
@chrisroberts chrisroberts removed this from the 1.10 milestone Oct 26, 2016
@ghost
Copy link

@ghost ghost commented Jul 13, 2017

Vagrant has the functionality there, but I can't seem to find anything about putting it in a vagrantfile.

Is there any current way to add an auto-removal of old boxes after update right in the vagrantfile, so all my devs can keep up to date painlessly?

@korotovsky
Copy link

@korotovsky korotovsky commented Jul 13, 2017

Hi @byanke-pcn,

We use vagrant-triggers plugin for that:

  if Vagrant.has_plugin?("vagrant-triggers")
    config.trigger.after :destroy do
      run "vagrant box prune --name company-name/box-name"
    end
  end

But anyways the workflow is:

$ vagrant destroy -f
$ vagrant box update
$ vagrant up
@benyanke
Copy link

@benyanke benyanke commented Jul 24, 2017

[I'm byanke-pcn/ghost above, I consolidated accounts]

I've been running the triggers commands, as well as running the prune manually, but I still end up with base boxes on my filesystem and appearing in virtualbox. For me, the prune seems to just be removing it from vagrant's interface, not from the computer.

Assistance?

@bbrala
Copy link
Contributor

@bbrala bbrala commented Jul 24, 2017

The prune command will internally run vagrant box remove [box] which removes it from the vagrant repository of boxes. Normally you find those in ~/vagrant.d/boxes.

If you mean removing them from your list of instances in VirtualBox you might have misunderstood the command. It will remove all old versions of installed boxed, and will not remove old instances from your VirtualBox (the machines created by vagrant up).

@benyanke
Copy link

@benyanke benyanke commented Jul 24, 2017

Is there any way to do so? Currently, as I understand it, vagrant can create but not delete boxes, which means it can't really fully automate the process, and must leave behind cruft.

@bbrala
Copy link
Contributor

@bbrala bbrala commented Jul 24, 2017

vagrant destroy in the correct project should just remove them :)

@benyanke
Copy link

@benyanke benyanke commented Jul 24, 2017

It doesn't though....

I run a destroy and prune nightly, and an up every morning (at least, sometimes I rebuild the box during the day too). After two weeks, I have several spare boxes just sitting in virtualbox taking up space.

@TomyLobo
Copy link

@TomyLobo TomyLobo commented Jul 29, 2017

@benyanke are you using linked clone mode?

@benyanke
Copy link

@benyanke benyanke commented Jul 29, 2017

@TomyLobo
Copy link

@TomyLobo TomyLobo commented Jul 30, 2017

That might be a factor here.

@bbrala
Copy link
Contributor

@bbrala bbrala commented Jul 30, 2017

There is an open issue about linked clones not getting cleaned somewhere in the issues actually. So yeah that is probably why then.

See #8277

@hashibot
Copy link

@hashibot hashibot bot commented Apr 1, 2020

I'm going to lock this issue because it has been closed for 30 days . This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@hashibot hashibot bot locked and limited conversation to collaborators Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.