Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant: vagrant up command gives "A box must be specified" error

I am getting this error when trying to run the "vagrant up" terminal command:

There are errors in the configuration of this machine. Please fix the following errors and try again:

*A box must be specified.

In my Homestead/.vagrant/machines/default/virtualbox folder, there is no file there, so I'm assuming that is what it's referring to when it says a box must be specified, however I don't know how to include a box as this is my first time using vagrant, and I've searched online with no resolve.

Anyone have a solution to this?

EDIT (Vagrantfile):

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION = "2"
confDir = $confDir ||= File.expand_path("~/.homestead")

homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
aliasesPath = confDir + "/aliases"

require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exists? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
    end

    if File.exists? homesteadYamlPath then
        Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
    elsif File.exists? homesteadJsonPath then
        Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
    end

    if File.exists? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath
    end
end
like image 418
Lansana Camara Avatar asked Jul 28 '15 02:07

Lansana Camara


People also ask

How do I increase RAM size in vagrant?

Change memory limit for Vagrant. v. customize ["modifyvm", :id, "--memory", 4096] #<= 4096 equals 4GB total memory. # Set the box name in VirtualBox to match the working directory.

What vagrant up does?

Command: vagrant up [name|id] This command creates and configures guest machines according to your Vagrantfile. This is the single most important command in Vagrant, since it is how any Vagrant machine is created. Anyone using Vagrant must use this command on a day-to-day basis.


2 Answers

Inside the homestead directory, you have to run the command bash init.sh.

This will generate the Homestead.yaml file (and after.sh and aliases) inside your home directory (~).

If you are changing Homestead.yaml again, you have to re-run bash init.sh again. It will ask for overwrite, say yes.

(also, be sure that the directory for folders: - map: exists)

like image 188
trogne Avatar answered Oct 03 '22 02:10

trogne


Fixed this by fixing my file paths in the homestead.yaml. When I made the installs in the terminal, a .homestead folder was being create outside of the main Homestead folder, which is what was causing my problems. But after changing the paths inside that .homestead/homestead.yaml to the same ones in my Homestead/homestead.yaml, the problem no longer persisted.

like image 33
Lansana Camara Avatar answered Oct 03 '22 03:10

Lansana Camara