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 · 30 comments

Comments

Projects
None yet
@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

This comment has been minimized.

Show comment
Hide comment
@chrisvire

chrisvire 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 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

This comment has been minimized.

Show comment
Hide comment
@chrisvire

chrisvire 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 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

Add script to clean up outdated boxes.
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

This comment has been minimized.

Show comment
Hide comment
@dbazhal

dbazhal Jun 30, 2015

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

dbazhal commented Jun 30, 2015

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

@everflux

This comment has been minimized.

Show comment
Hide comment
@everflux

everflux Aug 20, 2015

Can you just create a pull request for your proposal?

everflux commented Aug 20, 2015

Can you just create a pull request for your proposal?

@thom8

This comment has been minimized.

Show comment
Hide comment
@thom8

thom8 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.

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

This comment has been minimized.

Show comment
Hide comment
@kylegibson

kylegibson Jan 6, 2016

Has anyone started on this implementation?

kylegibson commented Jan 6, 2016

Has anyone started on this implementation?

@bbrala

This comment has been minimized.

Show comment
Hide comment
@bbrala

bbrala Jan 12, 2016

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@bbrala

bbrala Jan 12, 2016

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@bbrala

bbrala Jan 13, 2016

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@kylegibson

kylegibson Jan 13, 2016

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

kylegibson commented Jan 13, 2016

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

@dbazhal

This comment has been minimized.

Show comment
Hide comment
@dbazhal

dbazhal Jan 13, 2016

@bbrala Well done. Waiting for merge.

dbazhal commented Jan 13, 2016

@bbrala Well done. Waiting for merge.

@amontalban

This comment has been minimized.

Show comment
Hide comment
@amontalban

amontalban Feb 12, 2016

Contributor

+1

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

Contributor

amontalban commented Feb 12, 2016

+1

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

@vinceskahan

This comment has been minimized.

Show comment
Hide comment
@vinceskahan

vinceskahan Mar 9, 2016

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

vinceskahan commented Mar 9, 2016

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

@bbrala

This comment has been minimized.

Show comment
Hide comment
@bbrala

bbrala Mar 16, 2016

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@bbrala

bbrala Mar 17, 2016

Contributor

Ping @sethvargo

Contributor

bbrala commented Mar 17, 2016

Ping @sethvargo

@bbrala

This comment has been minimized.

Show comment
Hide comment
@bbrala

bbrala Apr 12, 2016

Contributor

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

Contributor

bbrala commented Apr 12, 2016

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

@vinceskahan

This comment has been minimized.

Show comment
Hide comment
@vinceskahan

vinceskahan 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 ----

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

This comment has been minimized.

Show comment
Hide comment
@GhostLyrics

GhostLyrics Jul 13, 2016

Is there any update on this?

GhostLyrics commented Jul 13, 2016

Is there any update on this?

@bbrala

This comment has been minimized.

Show comment
Hide comment
@bbrala

bbrala Jul 27, 2016

Contributor

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

Contributor

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 closed this in #7978 Nov 9, 2016

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost 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?

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

This comment has been minimized.

Show comment
Hide comment
@korotovsky

korotovsky 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

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

This comment has been minimized.

Show comment
Hide comment
@benyanke

benyanke 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?

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

This comment has been minimized.

Show comment
Hide comment
@bbrala

bbrala Jul 24, 2017

Contributor

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).

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@benyanke

benyanke 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.

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

This comment has been minimized.

Show comment
Hide comment
@bbrala

bbrala Jul 24, 2017

Contributor

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

Contributor

bbrala commented Jul 24, 2017

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

@benyanke

This comment has been minimized.

Show comment
Hide comment
@benyanke

benyanke 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.

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

This comment has been minimized.

Show comment
Hide comment
@TomyLobo

TomyLobo Jul 29, 2017

@benyanke are you using linked clone mode?

TomyLobo commented Jul 29, 2017

@benyanke are you using linked clone mode?

@benyanke

This comment has been minimized.

Show comment
Hide comment
@benyanke

benyanke commented Jul 29, 2017

@TomyLobo

This comment has been minimized.

Show comment
Hide comment
@TomyLobo

TomyLobo Jul 30, 2017

That might be a factor here.

TomyLobo commented Jul 30, 2017

That might be a factor here.

@bbrala

This comment has been minimized.

Show comment
Hide comment
@bbrala

bbrala Jul 30, 2017

Contributor

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

Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment