找不到框“laravel/homestead”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34946837/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Box 'laravel/homestead' could not be found
提问by MTVS
I have downloaded the laravel/homestead
box manually from here.
我已经laravel/homestead
从这里手动下载了这个盒子。
I successfully add the box:
我成功添加了框:
vagrant box add file:///path/to/the/laravel/homestead.box --name 'laravel/homestead'
but when I run vagrant up
it says: Box 'laravel/homestead' could not be found
even though vagrant box list
shows the box.
但是当我运行时vagrant up
它说:Box 'laravel/homestead' could not be found
即使vagrant box list
显示了框。
The download page says that run vagrant init laravel/homestead
that generates a vagrantfile
but the laravel/homestead
repository itself provides a vagrantfile
.
下载页面说运行vagrant init laravel/homestead
会生成一个,vagrantfile
但laravel/homestead
存储库本身提供了一个vagrantfile
.
I can vagrant up
with the vagrantfile
that is generated with vagrant init laravel/homestead
but it lacks the essential configs inside the laravel/homestead
repository's vagrantfile
.
我可以vagrant up
使用vagrantfile
生成的,vagrant init laravel/homestead
但它在laravel/homestead
存储库的vagrantfile
.
This is the vagrantfile
that is generated
这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
it has this setting:
它有这个设置:
Vagrant.configure(2) do |config|
config.vm.box = "laravel/homestead"
end
I tried to add this to the default laravel/homestead
's vagrantfile
but it didn't work.
我试图将它添加到默认的laravel/homestead
'svagrantfile
但它没有用。
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
What should I do?
我该怎么办?
回答by jaxim
The Vagrantfile provided by the laravel/homstead projectis more advanced than a generic Vagrantfile that is generated by vagrant init
laravel/homstead 项目提供的Vagrantfile比由生成的通用 Vagrantfile 更高级vagrant init
The Vagrantfile provided by the laravel/homstead project uses some ruby code to assist in setting up the vagrant environment. What we can see from the homestead ruby codeis that it is checking that you have a box with a version greater than or equal to 0.4.0:
laravel/homstead 项目提供的 Vagrantfile 使用了一些 ruby 代码来辅助搭建 vagrant 环境。我们可以从homestead ruby 代码中看到,它正在检查您是否有一个版本大于或等于 0.4.0 的框:
config.vm.box_version = settings["version"] ||= ">= 0.4.0"
config.vm.box_version = settings["version"] ||= ">= 0.4.0"
As you added the box manually you will see that it is present on your local machine:
当您手动添加该框时,您将看到它存在于您的本地机器上:
$ vagrant box list
laravel/homestead (virtualbox, 0)
Note however the number next to the provider is 0. That number is the box version. As the box was added manually the box metadata was not available and by default you will get a version of 0.
但请注意,提供商旁边的数字是 0。该数字是盒装版本。由于框是手动添加的,因此框元数据不可用,默认情况下您将获得版本 0。
When you now do a vagrant up
the code is checking if you have a box >= 0.4.0 which you don't have so is why you are getting Box 'laravel/homestead' could not be found
. It would then attempt to download the box at the minimal version required.
当你现在做一个vagrant up
代码时,代码会检查你是否有一个 >= 0.4.0 你没有的框,所以这就是为什么你得到Box 'laravel/homestead' could not be found
. 然后它会尝试以所需的最低版本下载该框。
To circumvent around this you could create a metadata.json file locally in the same directory as your downloaded box file. e.g:
为了避免这种情况,您可以在与下载的 box 文件相同的目录中在本地创建一个 metadata.json 文件。例如:
{
"name": "laravel/homestead",
"versions": [{
"version": "0.4.0",
"providers": [{
"name": "virtualbox",
"url": "file:///path/to/homestead.box"
}]
}]
}
Then run vagrant box add metadata.json
然后运行 vagrant box add metadata.json
This will install the box with a version and can be confirmed by:
这将安装带有版本的框,可以通过以下方式确认:
$ vagrant box list
laravel/homestead (virtualbox, 0.4.0)
You will now be able to perform vagrant up
using your local box.
您现在可以vagrant up
使用本地设备进行表演。
回答by Lwin Maung Maung
I have solved the problem by following. I test only on Mac El-capitan.
我已经通过以下方法解决了这个问题。我只在 Mac El-capitan 上测试。
vagrant box add laravel/homestead homestead.box
it shows the following:
它显示以下内容:
==> 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'!
And then I changed to vagrant file directory
然后我改成vagrant文件目录
cd ~/.vagrant.d/
Then list files and I saw My boxes
然后列出文件,我看到了我的盒子
cent hashicorp-VAGRANTSLASH-precise64 laravel-VAGRANTSLASH-homestead
and choose to laravel by cd laravel-VAGRANTSLASH-homestead
并选择通过 cd laravel-VAGRANTSLASH-homestead
and ls and see 0
和 ls 看看 0
I command by mv 0 0.4.0
我命令 mv 0 0.4.0
When I list by vagrant box list
当我列出 vagrant box list
cent (virtualbox, 0)
hashicorp/precise64 (virtualbox, 0)
laravel/homestead (virtualbox, 0.4.0)
Then I edit Vagrant Homestead file vi ~/Homestead/Vagrantfile
and add the following:
然后我编辑 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
and then vagrant up
进而 vagrant up
I hope it will works for some whose cannot add by metadata.json directly. Thanks.
我希望它适用于一些不能直接通过 metadata.json 添加的人。谢谢。
回答by den_ban
if someone have the same probelm and useing win, check if ms visual libraries are ok, the main is curl.
如果有人有相同的problem并使用win,请检查ms视觉库是否正常,主要是curl。
https://www.microsoft.com/en-us/download/confirmation.aspx?id=5555
https://www.microsoft.com/en-us/download/confirmation.aspx?id=5555
回答by Rai
Why download the box manually, if you can let Vagrant do all that for you?
如果您可以让 Vagrant 为您完成所有操作,为什么要手动下载该框?
As said in the homestead documentation:vagrant box add laravel/homestead
will add and download the box for you.
正如宅基地文档中所说:vagrant box add laravel/homestead
将为您添加和下载该框。
"If this command fails, you may have an old version of Vagrant that requires the full URL:"vagrant box add laravel/homestead https://atlas.hashicorp.com/laravel/boxes/homestead
“如果这个命令失败,你可能有一个需要完整 URL 的旧版本 Vagrant:”vagrant box add laravel/homestead https://atlas.hashicorp.com/laravel/boxes/homestead
You can add a box manually like so:vagrant box add laravel/homestead path/to/your/box/file.box
您可以像这样手动添加一个框:vagrant box add laravel/homestead path/to/your/box/file.box
回答by Divick
I followed the accepted answer but still it was trying to download the virtualbox "box". I had to modify the following settings in scripts/homestead.rb
我遵循了接受的答案,但它仍然试图下载虚拟机“盒子”。我不得不修改 scripts/homestead.rb 中的以下设置
#config.vm.box_version = settings["version"] ||= ">= 1.0.0"
config.vm.box_url = "file:///home/divick/Homestead/virtualbox.box"
Note I have commented out the version line because it was complaining with the following message:
注意我已注释掉版本行,因为它抱怨以下消息:
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.
回答by Abdullah R.
For anyone facing this issue, make sure you upgrade your vagrantand adding laravel/homestead
should get installed without issues.
对于遇到此问题的任何人,请确保升级您的流浪者并添加laravel/homestead
应该安装没有问题。