42

I misspelled the name of a box when I added it to my box list:

vagrant box list
debian
ubnutu

Can I rename the box without repackaging it?

iconoclast
  • 3,260
  • 6
  • 35
  • 38
Roberto Aloi
  • 1,193
  • 2
  • 15
  • 30

3 Answers3

48

You can simply rename the dir that represents the box. If your vagrant files are in their default dir (i.e. /path/to/your/home/.vagrant.d) you can just do:

mv vagrant_path/boxes/box_to_rename vagrant_path/boxes/new_box_name

Also be sure to change the Vagrantfile to use the new label for the box. You just need to change the config.vm.box directive to reflect the changes.

Tiago
  • 581
  • 3
  • 3
  • This didn't work for me - I suspect there is a config file somewhere that needs to be updated as well. @Till's suggestion worked. – Adrian Mouat Feb 11 '14 at 11:35
  • @AdrianMouat: Hmm, worked for me. Did you have VMs actively running with the box in question at the time of the rename? I could imagine that maybe causing problems, though I don't really know that or why it would, necessarily. What results did you get when you tried? – lindes-hw Nov 16 '14 at 06:36
  • @lindes-hw I've no idea, it was 10 months ago... – Adrian Mouat Nov 17 '14 at 09:13
  • @AdrianMouat: fair enough. Mostly, I just wanted to not have that comment left there un-responded-to, as it detracts (to my mind) from the idea of this being a correct answer, and yet, I think it is. If there are real problems with it, though, it would be good to hear about them - whether from you, or someone else who encounters them in the future. – lindes-hw Nov 17 '14 at 18:31
  • @lindes-hw It might be relevant that I was running on Mac OS. I don't believe I had actively running VMs at the time; I think I would have checked that. – Adrian Mouat Nov 18 '14 at 19:11
  • OK, well my test just now was also on MacOS. So I don't know... – lindes-hw Nov 19 '14 at 19:41
  • On Linux, the box would typically be in ~/.vagrant.d/boxes. So you can do `mv ~/.vagrant.d/boxes/ ~/.vagrant.d/boxes/` EDIT: Sorry, didn't catch the note in the parenthesis, I will leave the duplicate here anyway, since it is visually clearer for me and maybe others as well. – AdamKalisz Mar 20 '20 at 16:10
13

I would do this:

$ vagrant box repackage misspelled-name
[vagrant] Compressing package to: /Users/johndoe/package.box
$ vagrant box add correct-name /Users/johndoe/package.box
...

Not the worst to know about these two anyway, since you can frequently update base boxes (e.g. to update the kernel, software and guest additions) to avoid running all these required updates every time you vagrant up.

cjs
  • 918
  • 1
  • 6
  • 13
Till
  • 397
  • 3
  • 9
0

On windows, you can rename the box folder name here. C:\Users\uday.vagrant.d\boxes\

It will update automatically