免责声明:此问题与this不重复。该帖子中的解决方案(添加框时使用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
此输出的操作系统是Manjaro Linux(5.5.11-1-MANJARO),但我在Windows 10 1903内部版本18362.720上也遇到了相同的问题
答案 0 :(得分:1)
这是因为您为提供商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
或者在您的config.vm.provider
中修改Vagrantfile
。
请参见vagrant-libvirt#start-vm和Basic Provider Usage #Default Provider
否则,如果您不想使用libvirt
而是virtualbox
,则必须安装rhel
box for virtualbox