vagrant package breaks on undefined method

I have been using vagrant to develop chef cookbooks. Vagrant is a tool for managing virtualized development environments. When vagrant was initially launched supported VirtualBox only. As vagrant matured more providers were added like VMWare, AWS, Docker etc. I prefer using vagrant with its default provider, VirtualBox. I use vagrant 1.6.3 with ruby 1.9.3p547 on my Ubuntu 12.04 Lenovo U410 ultrabook.

I use box-cutter’s boxes as my initial boxes to build upon those. They are excellent default bare boxes without much software installed. You can find there boxes for centos, debian, fedora, ubuntu and many others.

Since chef is not installed in this boxes one of the change I make is install it but this should be done every time that I will be launching a vagrant box. So once chef is installed we can package the new box with using vagrant package command. Unfortunately because of a bug when I execute

$ vagrant package --output --base "box-cutter/centos511-i386" --vagrantfile Vagrantfile
==> box-cutter/centos511-i386: VM not created. Moving on...

Searching on vagrant’s github issues I found a solution as proposed here

It turned out to be that I was using incorrect base name. It is not the name of the box (box-cutter/centos511-i386) you use but the name as it is used from VirtualBox. You can get its name executing the following command

$ VBoxManage list vms
"ubuntu-12.04-server-i386" {278b787e-1e05-425f-ad52-5804c4405b09}
"CentOS 6" {658b2e26-fab5-4b2e-bcc0-a3020bfc1ce4}
"centos5_default_1416400560587_23130" {cc26e3b7-236b-4568-8644-0f362bd0c5df}

The first 2 boxes are the ones I have directly used on VirtualBox without vagrant. The last one is the vagrant box. So in order to package the modified box execute

$ vagrant package --base centos5_default_1416400560587_23130 --output

Last step is to add the packaged box in the list of vagrant boxes

$ vagrant box add box-dimka/centos511-i386


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s