简体   繁体   中英

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

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)

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.

Use homestead up instead of vagrant up , if you are using homestead package. It already knows where all files are and will up you VM easily.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM