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?

0

3 Answers 3

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.

7
  • 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. Commented Feb 11, 2014 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
    Commented Nov 16, 2014 at 6:36
  • @lindes-hw I've no idea, it was 10 months ago... Commented Nov 17, 2014 at 9: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
    Commented Nov 17, 2014 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. Commented Nov 18, 2014 at 19:11
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.

4
  • Is it okay to delete the package.box file when this is done? Commented Oct 8, 2012 at 0:33
  • 1
    @PeterHanley Yep. Once imported, it's ok to get rid off it.
    – Till
    Commented Oct 8, 2012 at 16:35
  • 2
    Note that this will take much longer than simply renaming the underlying file, and does lots of extra work that's probably not necessary in most (all?) cases.
    – lindes-hw
    Commented Nov 16, 2014 at 6:37
  • @lindes-hw can you show a better way? And why? Commented Feb 23, 2016 at 6:15
0

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

It will update automatically

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .