Vagrant Config Error - "A box must be specified."

18,949

Solution 1

Inside of your machine definitions, you need to use the variable name of that machine, instead of config. Try this out:

In the file below, I've changed config.vm to either php5dot3.vm or php5dot6.vm:

Vagrant.configure("2") do |config|

    # Globally defined variables
    config.vm.synced_folder "./", "/var/www/public"

    # CentOS 6.5, Apache 2.2.15, MySQL 5.5.36 (-u root), PHP 5.3.28
    # Note: If PHP session keys don't work, set permissions to 777 (or other more restrictive, but this is guaranteed to work) on /var/lib/php/session
    config.vm.define "php5dot3", primary: true do |php5dot3|
        php5dot3.vm.box = "smallhadroncollider/centos-6.5-lamp"
        php5dot3.vm.network :forwarded_port, guest: 80, host: 4567
    end

    # Ubuntu 14.04 (SSH pw: vagrant), Apache 2.4.12, MySQL 5.5.43 (-u root -p root), PHP 5.6.10
    config.vm.define "php5dot6", autostart:false do |php5dot6|
        php5dot6.vm.box = "scotch/box"
        php5dot6.vm.network :forwarded_port, guest: 80, host: 4568
    end

end

I also added autostart:false to the definition of your php5dot6 box, which you can remove if you wish. (It just means that running vagrant up will only start the primary by default.

Solution 2

If you are getting this error with DigitalOcean, you may need their plugin:

vagrant plugin install vagrant-digitalocean
Installing the 'vagrant-digitalocean' plugin. This can take a few minutes...
Fetching: multipart-post-2.0.0.gem (100%)
Fetching: faraday-0.15.4.gem (100%)
Fetching: vagrant-digitalocean-0.9.3.gem (100%)

Solution 3

For someone that is having this issue now:

I had deleted my Vagrantfile before trying to destroy it. You need to run the vagrant destroy command from the right directory where the Vagrantfile for that process is.

Run vagrant ssh-config and look at the directory column.

If you, like me, deleted the file, do:

vagrant init

Then

vagrant destroy $id

P.S.: Use sudo if you have permission issues running those commands.

Share:
18,949
Sam A. Horvath-Hunt
Author by

Sam A. Horvath-Hunt

Hi there! I'm a software engineer based in London, working remotely, with a passion for pure functional programming. For more, check out: https://samhh.com/resume

Updated on June 06, 2022

Comments

  • Sam A. Horvath-Hunt
    Sam A. Horvath-Hunt almost 2 years

    The boxes were working fine. Then I halted one (the only one running at the time) and now I can't get either of them back up.


    Running vagrant up [name] gives me the following error, regardless of which I pick or whether I leave it at vagrant up for them both to come up:

    There are errors in the configuration of this machine. Please fix
    the following errors and try again:
    
    vm:
    * A box must be specified.
    

    Running latest version of Vagrant (1.7.4).

    Here is my Vagrantfile in its entirety, comments included (just in case):

    # Search for boxes here: https://atlas.hashicorp.com/boxes/search
    # Refer to commands_vagrant.txt for command reference
    
    Vagrant.configure("2") do |config|
    
        # Globally defined variables
        config.vm.synced_folder "./", "/var/www/public"
    
        # CentOS 6.5, Apache 2.2.15, MySQL 5.5.36 (-u root), PHP 5.3.28
        # Note: If PHP session keys don't work, set permissions to 777 (or other more restrictive, but this is guaranteed to work) on /var/lib/php/session
        config.vm.define "php5dot3", primary: true do |php5dot3|
            config.vm.box = "smallhadroncollider/centos-6.5-lamp"
            config.vm.network :forwarded_port, guest: 80, host: 4567
        end
    
        # Ubuntu 14.04 (SSH pw: vagrant), Apache 2.4.12, MySQL 5.5.43 (-u root -p root), PHP 5.6.10
        config.vm.define "php5dot6" do |php5dot6|
            config.vm.box = "scotch/box"
            config.vm.network :forwarded_port, guest: 80, host: 4568
        end
    
    end
    

    Result of running vagrant status:

    Current machine states:
    
    php5dot3                  poweroff (virtualbox)
    php5dot6                  poweroff (virtualbox)
    

    Result of running vagrant global-status:

    id       name     provider   state    directory                           
    --------------------------------------------------------------------------
    e1f3c85  default  virtualbox poweroff /home/sam/Web                       
    c588d51  php5dot6 virtualbox poweroff /home/sam/Web                       
    4e71c50  php5dot3 virtualbox poweroff /home/sam/Web    
    

    'default' was the singular box I had in my Vagrantfile before I got multi-machines working last week. (Relevant?)


    Result of running vagrant box list:

    scotch/box                          (virtualbox, 2.0)
    smallhadroncollider/centos-6.5-lamp (virtualbox, 1.0.0)
    

    Any help would be appreciated, thanks.

  • Sam A. Horvath-Hunt
    Sam A. Horvath-Hunt about 8 years
    This seems to have fixed my long-standing issue with Vagrant. Thank you so much!
  • Brian Vanderbusch
    Brian Vanderbusch about 8 years
    Wish you hadn't had to wait 4 months for the issue to be resolved!
  • Parthian Shot
    Parthian Shot about 8 years
    Bright side? Problem solved! Flip side? ...How did I not figure this out... :/
  • SiliconMachine
    SiliconMachine over 4 years
    This solved my problem for DigitalOcean on Vagrant 2.2.5. Thank you!
  • FlyingV
    FlyingV over 4 years
    You are welcome my friend. I am glad I could save someone some time. If this was helpful please upvote so others can find it as well.