无法启动vagrant - 如何设置"providers"

69
我正在尝试运行Vagrant,但在执行vagrant up命令后出现错误:
No usable default provider could be found for your system.

Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.

The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.

If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.

我之前安装了VirtualBox版本4.3.26 r989888和Linux Ubuntu(64位)。

之后执行以下命令:

vagrant box add precise32 http://files.vagrantup.com/precise32.box

==> box: 正在为提供程序添加'precise32'(v0): box: 正在下载:http://files.vagrantup.com/precise32.box box: 进度:100%(速率:1425k/s,剩余时间:--:--:--) ==> box: 成功为'virtualbox'添加'precise32'(v0)!

当我执行以下命令时:

vagrant box list

lucid32   (virtualbox, 0)
precise32 (virtualbox, 0)

"Provider"存在什么问题

vagrant package --base vagrant-ubuntu64

(翻译:vagrant打包--基于vagrant-ubuntu64)
Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed.

Vagrant uses the `VBoxManage` binary that ships with VirtualBox, and requires
this to be available on the PATH. If VirtualBox is installed, please find the
`VBoxManage` binary and add it to the PATH environmental variable.

如何帮助他检测VirtualBox?

2
错误信息显示Vagrant无法访问VBoxManage。打开终端,输入VBoxManage并检查是否被识别。如果没有被识别,则在文件系统中找到VBox的位置(其中您将看到VBoxManage),并按照Vagrant消息的指示将其添加到PATH中。这应该能解决问题。 - Arek Czarnogłowski
8个回答

55

快速提示 - Vagrant 1.8.4和Virtualbox 5.1.X在MacOS 10.11上不兼容(无法设置提供程序)。

Virtualbox 5.0.10完全正常运行。


1
哥们儿!救星啊,这应该是OSx 10.11的答案。 - feilong
正确。不幸的是,vagrant up 没有报告这一点。作为记录:vagrant package --base trustyVagrant 检测到您安装了一个不受此版本 Vagrant 支持的 VirtualBox 版本。请安装下面列出的支持版本之一以使用 Vagrant:4.0、4.1、4.2、4.3、5.0 - Steffo
2
FYI:Vagrant 1.8.5 应该可以与 5.1 兼容(刚在 Github 上检查了 Vagrant 的更改日志),但截至今天尚未发布。 - gottlike
1
已验证此修复程序,这是错误:https://github.com/mitchellh/vagrant/issues/7578 - Taylor Hughes
1
在使用Vagrant 1.9.1与较旧版本的VirtualBox时,我遇到了类似的问题。但是,当我安装了VirtualBox 5.1时,一切都运行得很完美。 - Teddy Belay
显示剩余4条评论

23

我只需安装最新版本的Vagrant(截至本文撰写时为1.7.4),即可轻松解决此问题。


1
我使用的是Vagrant 1.7.2和VirtualBox 5.0.8,升级到Vagrant 1.7.4后问题也得到了解决。 - icc97
1
实际上,1.7.4版本对我只有部分进展。最终解决问题的方法是从项目目录中删除“.vagrant”文件夹。 - Ricky Nelson
2
谢谢!更新到Vagrant 1.8.1和VirtualBox 5.0.10对我也起作用了。不需要删除.vagrant文件。现在有人能告诉我们为什么吗? :) - Valerie Parham-Thompson

22

只需要尝试启动Vagrant并指定您想要使用的提供程序:

vagrant up --provider virtualbox

根据下面的截图,它会告诉您指定提供程序不能工作的原因。在我的情况下,是VirtualBox 5.2的不支持版本。我需要将其降级到v5.1。

enter image description here


这对我起作用了。我尝试使用的是Vagrant不支持的VirtualBox v6.1.0版本。谢谢,Clayton。 - claytonjwong

8

自VirtualBox 4.3.12以来,似乎已经报告了一个问题

VirtualBox会自动创建以下环境变量VBOX_MSI_INSTALL_PATH

然而,如果您搜索base.rb文件,vagrant使用变量VBOX_INSTALL_PATH

所以您可以: - 更新变量名VBOX_MSI_INSTALL_PATH并将其更改为VBOX_INSTALL_PATH - 创建一个新的变量名VBOX_INSTALL_PATH,其值与VBOX_MSI_INSTALL_PATH相同

提醒在Windows上,转到我的电脑(右键单击)-->属性-->高级系统设置-->环境变量,查找您需要管理的变量


感谢您提供最深入和富有洞见的答案。在其他关于同一主题的帖子中,许多回复都是泛泛而谈的“这对我有用”,却没有解释根本原因和可行的解决方案。 - truedat101

5

好的,我遇到了与Windows、Vagrant和VirtualBox相关的同样问题,做了以下操作。

  1. 在Windows桌面上单击"This PC" / "My Computer"
  2. 选择"属性"
  3. 转到"高级"选项卡
  4. 在底部单击"环境变量..."
  5. 在系统变量下单击"新建..."
  6. 将"变量名称"设置为"VBOX_INSTALL_PATH"
  7. 将"变量值"设置为"C:\Program Files\Oracle\VirtualBox\"
  8. 选择"确定"并关闭所有其他设置窗口

感谢这里的贡献: https://github.com/mitchellh/vagrant/issues/3852

我假设有一个环境变量(或者对于Linux用户来说是PATH),需要指定虚拟机可执行文件的路径。


2

我正在运行macOS 10.12,使用homebrew安装了vagrant 5.1。

我遇到了与OP相同的错误,并通过下载最新版本的VirtualBox(v5.1.6)来解决它。

注意:该版本在下载页上被标记为amd64,这只是64位标准的名称,在Intel macs上也可以正确安装。


2

我在Mac上安装了Virtualbox 6.1和Vagrant 2.2.6,但是遇到了错误。我不得不将Virtualbox还原为6.0,然后使用vagrant up命令才能与ubuntu/trusty64配合使用。请参考@Serge Voloshenko的答案,了解如何发现是否存在兼容性问题。


0

这可能只是版本问题,可能是vagrant或Virtual box连接的问题。

尝试这个命令:vagrant up --provider virtualbox

如果virtual box的版本兼容,则上述命令将有所帮助,并且它还会建议当前可链接的Virtual box版本。

目前,4.0、4.1、4.2、4.3、5.0、5.1、5.2是可用的Virtual box版本。

顺便说一下,如果您担心Vagrant的版本,我已经尝试了当前版本:2.0.3。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接