Подтвердить что ты не робот

Ящик "laravel/homestead" не найден

Я загрузил поле laravel/homestead вручную из здесь.

Я успешно добавлю окно:

vagrant box add file:///path/to/the/laravel/homestead.box --name 'laravel/homestead'

но когда я запустил vagrant up, он говорит: Box 'laravel/homestead' could not be found, хотя vagrant box list показывает окно.

На странице загрузки говорится, что запустите vagrant init laravel/homestead, который генерирует vagrantfile, но сам репозиторий laravel/homestead предоставляет vagrantfile.

Я могу vagrant up с vagrantfile, который сгенерирован с помощью vagrant init laravel/homestead, но ему не хватает основных конфигураций внутри репозитория laravel/homestead vagrantfile.

Это vagrantfile, который сгенерирован

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "laravel/homestead"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
  # such as FTP and Heroku are also available. See the documentation at
  # https://docs.vagrantup.com/v2/push/atlas.html for more information.
  # config.push.define "atlas" do |push|
  #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
  # end

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   sudo apt-get update
  #   sudo apt-get install -y apache2
  # SHELL
end

он имеет эту настройку:

Vagrant.configure(2) do |config|  
    config.vm.box = "laravel/homestead"
end

Я попытался добавить это значение по умолчанию laravel/homestead 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

    ## HERE I added the setting ############################################
    config.vm.box = "laravel/homestead"
    ########################################################################
end

Что мне делать?

4b9b3361

Ответ 1

Vagrantfile, предоставленный проект laravel/homstead, более продвинут, чем общий Vagrantfile, который генерируется vagrant init

В Vagrantfile, предоставленном проектом laravel/homstead, используется некоторый код ruby, чтобы помочь в настройке бродячего окружения. Что мы можем видеть из homestead ruby ​​code в том, что он проверяет, что у вас есть ящик с версией, большей или равной 0,4.0

config.vm.box_version = settings["version"] ||= ">= 0.4.0"

Когда вы добавили поле вручную, вы увидите, что оно присутствует на вашем локальном компьютере:

$ vagrant box list
laravel/homestead               (virtualbox, 0)

Обратите внимание, что номер рядом с провайдером равен 0. Этот номер является коробкой. Поскольку ящик был добавлен вручную, метаданные ящика недоступны, и по умолчанию вы получите версию 0.

Когда вы выполняете vagrant up, код проверяет, есть ли у вас поле >= 0.4.0, которого у вас нет, поэтому вы получаете Box 'laravel/homestead' could not be found. Затем он попытается загрузить окно с минимальной требуемой версией.

Чтобы обойти это, вы можете создать файл metadata.json локально в том же каталоге, что и загруженный файл окна. например:

{
    "name": "laravel/homestead",
    "versions": [{
        "version": "0.4.0",
        "providers": [{
            "name": "virtualbox",
            "url": "file:///path/to/homestead.box"
        }]
    }]
}

Затем запустите vagrant box add metadata.json

Это установит окно с версией и может быть подтверждено:

$ vagrant box list
laravel/homestead               (virtualbox, 0.4.0)

Теперь вы можете выполнить vagrant up с помощью своего локального поля.

Ответ 2

Я решил проблему, следуя. Я тестирую только на Mac El-capitan.

vagrant box add laravel/homestead homestead.box

показывает следующее:

==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'laravel/homestead' (v0) for provider: 
    box: Unpacking necessary files from: file:///Users/lwinmaungmaung/Vagrant%20Boxes/Homestead/homestead.box
==> box: Successfully added box 'laravel/homestead' (v0) for 'virtual box'!

И затем я перешел в каталог бродячих файлов

cd ~/.vagrant.d/

Затем список файлов, и я увидел Мои боксы

cent   hashicorp-VAGRANTSLASH-precise64      laravel-VAGRANTSLASH-homestead

и выберите laravel на cd laravel-VAGRANTSLASH-homestead

и ls и см. 0

Я команду mv 0 0.4.0

Когда я перечислил vagrant box list

cent                (virtualbox, 0)
hashicorp/precise64 (virtualbox, 0)
laravel/homestead   (virtualbox, 0.4.0)

Затем я редактирую файл Vagrant Homestead vi ~/Homestead/Vagrantfile и добавьте следующее:

config.vm.box = "laravel/homestead"
config.vm.box_url = "https://atlas.hashicorp.com/laravel/homestead"
config.vm.box_version = "0.4.0"
config.vm.box_check_update = false

а затем vagrant up

Я надеюсь, что это сработает для тех, чей не может добавить метаданные .json напрямую. Спасибо.

Ответ 4

Зачем загружать окно вручную, если вы можете позволить Vagrant сделать все, что для вас?

Как указано в документации на усадьбу:
vagrant box add laravel/homestead добавит и загрузит окно для вас.

"Если эта команда не удалась, у вас может быть старая версия Vagrant, для которой требуется полный URL-адрес:"
vagrant box add laravel/homestead https://atlas.hashicorp.com/laravel/boxes/homestead

В любом случае, вы можете добавить окно вручную так:
vagrant box add laravel/homestead path/to/your/box/file.box

Как установить Загруженный вручную .box для Vagrant

Ответ 5

Я последовал за принятым ответом, но все же пытался загрузить виртуальный бокс. Мне пришлось изменить следующие настройки в скриптах /homestead.rb

#config.vm.box_version = settings["version"] ||= ">= 1.0.0"                 
config.vm.box_url = "file:///home/divick/Homestead/virtualbox.box"          

Примечание. Я прокомментировал строку версии, потому что она жаловалась на следующее сообщение:

Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Box 'laravel/homestead' could not be found. Attempting to find and install...
    homestead-7: Box Provider: virtualbox
    homestead-7: Box Version: >= 1.0.0
==> homestead-7: Box file was not detected as metadata. Adding it directly...
You specified a box version constraint with a direct box file
path. Box version constraints only work with boxes from Vagrant
Cloud or a custom box host. Please remove the version constraint
and try again.