Vagrant up 因本地可用框而失败

Vagrant up fails with a locally available box

免责声明:此问题与 this 不重复。 post 的解决方案(添加框时使用 file:// 协议)没有解决我的问题。

我是 Vagrant 的新手。下载了一个自定义框,因为我需要调查有关此特定框的一些信息。我不能让流浪汉去上班。它失败了,因为 Vagrant 试图从本地文件下载我已经安装的盒子。

这是我的控制台输出:

[andymac@x58Manjaro Boxes]$ pwd
/home/andymac/Boxes

[andymac@x58Manjaro Boxes]$ ls -la
total 737884
drwxr-xr-x  2 andymac andymac      4096 Mar 25 10:21 .
drwxr-xr-x 41 andymac andymac      4096 Mar 25 10:15 ..
-rwxrwxrwx  1 andymac andymac 755579528 Mar 25 09:42 rhel-7.8-beta-1-mlnx-x86_64.2002.01.libvirt.box

[andymac@x58Manjaro Boxes]$ vagrant box add rhel-7.8-beta1 file:///home/andymac/Boxes/rhel-7.8-beta-1-mlnx-x86_64.2002.01.libvirt.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'rhel-7.8-beta1' (v0) for provider: 
    box: Unpacking necessary files from: file:///home/andymac/Boxes/rhel-7.8-beta-1-mlnx-x86_64.2002.01.libvirt.box
==> box: Successfully added box 'rhel-7.8-beta1' (v0) for 'libvirt'!

[andymac@x58Manjaro Boxes]$ vagrant box list
rhel-7.8-beta1 (libvirt, 0)

[andymac@x58Manjaro Boxes]$ vagrant init rhel-7.8-beta1
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

[andymac@x58Manjaro Boxes]$ ls -la
total 737888
drwxr-xr-x  2 andymac andymac      4096 Mar 25 10:24 .
drwxr-xr-x 41 andymac andymac      4096 Mar 25 10:15 ..
-rwxrwxrwx  1 andymac andymac 755579528 Mar 25 09:42 rhel-7.8-beta-1-mlnx-x86_64.2002.01.libvirt.box
-rw-r--r--  1 andymac andymac      3020 Mar 25 10:24 Vagrantfile

[andymac@x58Manjaro Boxes]$ vagrant box list
rhel-7.8-beta1 (libvirt, 0)

[andymac@x58Manjaro Boxes]$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'rhel-7.8-beta1' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'rhel-7.8-beta1' (v0) for provider: virtualbox
    default: Downloading: rhel-7.8-beta1
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

Couldn't open file /home/andymac/Boxes/rhel-7.8-beta1

OS 对于此输出是 Manjaro Linux (5.5.11-1-MANJARO),但我也 运行 在 Windows 10 1903 上遇到了同样的问题构建 18362.720

这是因为您为 provider 安装了一个盒子 libvirt:

==> box: Successfully added box 'rhel-7.8-beta1' (v0) for 'libvirt'!

[andymac@x58Manjaro Boxes]$ vagrant box list
rhel-7.8-beta1 (libvirt, 0)

然后您尝试 运行 使用 默认提供程序 virtualbox:

Bringing machine 'default' up with 'virtualbox' provider...

您需要 运行 使用 提供商 libvirt,使用此命令:

vagrant up --provider=libvirt

设置提供程序的其他方法是设置环境变量:

export VAGRANT_DEFAULT_PROVIDER=libvirt

或修改Vagrantfile中的config.vm.provider

vagrant-libvirt#start-vm and Basic Provider Usage #Default Provider


否则如果你不想使用 libvirtvirtualbox 你必须安装一个 rhel box for virtualbox