Laravel 盒子';拉雷维尔/家园和#x27;找不到
我已从手动下载了Laravel 盒子';拉雷维尔/家园和#x27;找不到,laravel,vagrant,vagrantfile,homestead,Laravel,Vagrant,Vagrantfile,Homestead,我已从手动下载了laravel/homestead框 我已成功添加该框: vagrant box add file:///path/to/the/laravel/homestead.box --name 'laravel/homestead' 但是当我运行Wagrant up时,它说:Box'laravel/homestead'无法找到,即使Wagrant Box list显示了该框 下载页面显示运行vagrant init laravel/homestad生成vagrant文件,但larav
laravel/homestead
框
我已成功添加该框:
vagrant box add file:///path/to/the/laravel/homestead.box --name 'laravel/homestead'
但是当我运行Wagrant up时,它说:Box'laravel/homestead'无法找到
,即使Wagrant Box list
显示了该框
下载页面显示运行vagrant init laravel/homestad
生成vagrant文件
,但laravel/homestad
存储库本身提供了一个vagrant文件
我可以vagrant up
使用vagrant init laravel/homestad
生成的vagrant文件
,但它缺少laravel/homestad
存储库的vagrant文件
中的基本配置
这是生成的vagrant文件
# -*- 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
我试图将此添加到默认的laravel/homestad
的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
我该怎么办?如果你能让流浪汉帮你做这些,为什么要手动下载这个盒子 如宅地文件所述:
vagrant box add laravel/homestad
将为您添加并下载该框
“如果此命令失败,您可能有一个旧版本的Vagrant,它需要完整的URL:”流浪者箱添加laravel/宅地https://atlas.hashicorp.com/laravel/boxes/homestead
您可以手动添加一个框,如下所示:vagrant box添加laravel/homestad path/to/your/box/file.box
由提供的vagrant文件比由
vagrant init生成的通用vagrant文件更高级
laravel/homstead项目提供的vagrant文件使用一些ruby代码来帮助设置vagrant环境。我们可以从中看到,它正在检查您是否有一个版本大于或等于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,而你没有,这就是为什么你无法找到盒子'laravel/homestad'。然后,它将尝试以所需的最低版本下载该框
为了避免这种情况,您可以在本地创建一个metadata.json文件,该文件与您下载的box文件位于同一目录中。e、 g:
{
"name": "laravel/homestead",
"versions": [{
"version": "0.4.0",
"providers": [{
"name": "virtualbox",
"url": "file:///path/to/homestead.box"
}]
}]
}
然后运行vagrant框add metadata.json
这将安装具有版本的机箱,并可通过以下方式进行确认:
$ vagrant box list
laravel/homestead (virtualbox, 0.4.0)
现在,您可以使用本地框执行vagrant up
。我已通过以下方法解决了问题。我只在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'!
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文件目录
cd ~/.vagrant.d/
vagrant up
然后列出文件,我看到了我的盒子
cent hashicorp-VAGRANTSLASH-precise64 laravel-VAGRANTSLASH-homestead
并选择通过cd-laravel-vagrant-slash-homestade
和ls,请参见0
通过mv0.4.0
当我按vagrant box list
cent (virtualbox, 0)
hashicorp/precise64 (virtualbox, 0)
laravel/homestead (virtualbox, 0.4.0)
然后我编辑流浪者家园文件vi~/homestad/Vagrantfile
并添加以下内容:
==> 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'!
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
然后流浪起来
我希望它能适用于那些不能直接通过metadata.json添加的用户。谢谢。如果有人有同样的问题并且正在使用win,请检查ms visual libraries是否正常,主要问题是curl
我遵循了公认的答案,但它仍然试图下载virtualbox“box”。我不得不在scripts/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.
对于遇到此问题的任何人,请确保您和添加的laravel/homestead
安装时不会出现问题。El Capitan OS
流浪汉2.2.14
虚拟盒6
转到您的目录,如:/user/(name)/homestad/scripts
这个目录是进行vagrant init和其他安装过程的地方
使用升华文本或文本编辑器打开homestad.rb文件,然后更改以下内容:
==> 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'!
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
config.vm.box_version=settings['version']| |='~> 9'
到
config.vm.box_version=settings['version']| |='>= 10.1.1“
经过这些改变后,你可以在目录中开始你的流浪汉
cd ~/.vagrant.d/
vagrant up
这将需要几分钟时间才能将您的盒子导入virtualbox。我的连接速度慢。旧版本的vagrant导致我出现此问题。升级到最新版本并升级插件修复了所有问题。非常感谢,我无法vagrant box添加metadata.json
,所以我只是在homestead.rb
中将box\u版本编辑为=0
谢谢,但我也认为我们需要小心在metadata.json文件中添加正确的版本。这正是我所寻找的。2年后仍然是正确答案,谢谢!很有魅力!!但我还必须在“laravel VagarantSlash homestead”目录中添加一个名为“metadata_url”的文件,其中包含以下内容:“”。