3
votes

I am pretty new to Vagrant and already I seem to have hit a snag with it. I am basically following their get started guide.

When I type the command:

$ vagrant box add hashicorp/precise64

I get this error:

The box you're attempting to add already exists. Remove it before adding it again or add it with the --force flag.

Name: hashicorp/precise64 Provider: virtualbox Version: 1.1.0

Here is what I have tried.

I destroyed it first using:

$ vagrant destroy

I then backed out into documents using:

$ cd -

I then removed the director with:

$ rm -rf vagrant_getting_started

Then I created a new directory with:

$ mkdir vagrant_getting_started

I then went into that directory with:

$ cd vagrant_getting_started

Then I typed:

$ vagrant box add hashicorp/precise64

Which gave me:

==> box: Loading metadata for box 'hashicorp/precise64' box: URL: https://vagrantcloud.com/hashicorp/precise64 This box can work with multiple providers! The providers that it can work with are listed below. Please review the list and choose the provider you will be working with.

1) hyperv

2) virtualbox

3) vmware_fusion

Enter your choice:

Finally I chose option 2 and then this is where the error is.

Can anyone see anything that I am doing wrong?

2
you already got that box installed, so why are you trying to add it again, default box location for Mac/linux systems is ~/.vagrant.d/boxes.xanadev

2 Answers

2
votes

Unless the Vagrant box image has become corrupted, you don't need to download it again to re-use it.

Vagrant only downloads the boxes it doesn't have. Once a box image is saved locally on your system, Vagrant will use the local image to work from.

When setting up a new Vagrant based project, the following will happen:

  • You create or navigate to your project directory

  • Run vagrant init hashicorp/precise64. This will initialise Vagrant inside the directory, and create a new Vagrantfile if one doesn't exist. It also tells Vagrant which box image to use. If the box image is already stored locally - it won't download it.

  • Alternatively, if you already have a Vagrantfile in your project directory, simply run vagrant up. Vagrant will take care of everything for you - including downloading the box image (if applicable).

1
votes

vagrant box remove -f laravel/homestead will remove the "laravel/homestead" from your machine and you can reinstall the same by vagrant box add laravel/homestead.