22

Ran "vagrant up" and did some changes. Want to go back to a clean installation. How do you reset vagrant back to it's original state? Do you run "vagrant destroy" and then "vagrant up" or do you "vagrant box remove" and then "vagrant up"

Albert T. Wong
  • 369
  • 1
  • 3
  • 8
  • 9
    `vagrant destroy && vagrant up` should do it. – ceejayoz Sep 24 '15 at 19:27
  • @ceejayoz does it redownload the image? – Albert T. Wong Sep 25 '15 at 19:44
  • I believe it'll cache box files and reuse them. As long as you don't blow away your `~/.vagrant.d/boxes` folder it'll be there. – ceejayoz Sep 25 '15 at 19:49
  • @ceejayoz It doesnt cache the file!! if your box file is hosted somewhere outside yor lan, it could take quite a long time to re-download. – Paolo Vigori Jan 25 '17 at 18:30
  • @PaoloV That's not the case for me. Check your `~/.vagrant.d/boxes` folder's permissions, perhaps. – ceejayoz Jan 25 '17 at 18:31
  • @ceejayoz you may have a copy in your home folder but if in the vagrant it says config.vm.box = http://.. when you destroy it also gets remove enirely from the system. It is very clear in the documentation. – Paolo Vigori Jan 25 '17 at 19:19
  • 1
    @PaoloV Ah. My box config is the `config.vm.box = "ubuntu/trusty64"` sort from the public registry. – ceejayoz Jan 25 '17 at 19:24
  • After I well and truly ruined my vagrant box. I tried the above, `vagrant destroy` and `vagrant up`, but they did not work. Instead `vagrant reload` did. Try this if in doubt. – Josh Miller Sep 08 '17 at 10:39

1 Answers1

24

@ceejayoz's comment is right:

vagrant destroy && vagrant up

worked for me.

wal
  • 147
  • 3
  • 12
Stan James
  • 381
  • 2
  • 8
  • Yes, `destroy` (according to the Vagrant book) returns everything back to the pristine state, as if you never ran `up` in the first place. – Geremia Sep 16 '16 at 21:50
  • 1
    @Geremia but also remove it from local computer so if hosted outside the lan you have to consider that too – Paolo Vigori Jan 25 '17 at 18:31
  • This does not always work: `vagrant destroy Vagrant failed to initialize at a very early stage: The plugins failed to load properly. The error message given is shown below. cannot load such file -- vagrant/share` – Alexander Nov 09 '18 at 13:42