簡體   English   中英

Vagrant:vagrant up命令給出“必須指定一個框”錯誤

[英]Vagrant: vagrant up command gives “A box must be specified” error

我在嘗試運行“vagrant up”終端命令時遇到此錯誤:

本機的配置存在錯誤。 請修正以下錯誤,然后重試:

*必須指定一個方框。

在我的Homestead/.vagrant/machines/default/virtualbox文件夾中,那里沒有文件,所以我假設這是指它必須指定一個盒子時指的是什么,但是我不知道如何包含因為這是我第一次使用流浪漢,我在線搜索沒有決心。

有人有解決方案嗎?

編輯(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

在宅基目錄中,您必須運行命令bash init.sh

這將在您的主目錄( ~ )中生成Homestead.yaml文件(以及after.shaliases )。

如果您再次更改Homestead.yaml ,則必須再次重新運行bash init.sh 它會要求覆蓋,說是。

(另外,請確保folders: - map:的目錄folders: - map: exists)

通過修復homestead.yaml中的文件路徑來解決這個問題。 當我在終端中進行安裝時,在Hometead主文件夾之外創建了一個.homestead文件夾,這就是導致我出現問題的原因。 但在將.homestead / homestead.yaml內部的路徑更改為我的Homestead / homestead.yaml中的相同路徑后,問題不再持續存在。

如果您使用宅基地包,請使用homestead up而不是vagrant up 它已經知道所有文件的位置,並且可以輕松地為您提供VM。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM