【问题标题】:Vagrant up fails with a locally available boxVagrant up 因本地可用的盒子而失败
【发布时间】:2020-07-05 19:20:00
【问题描述】:

免责声明:此问题与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 build 18362.720 上也遇到了同样的问题

【问题讨论】:

    标签: vagrant vagrantfile vagrant-windows


    【解决方案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...
    

    您需要使用 provider libvirt 运行它,使用以下命令:

    vagrant up --provider=libvirt
    

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

    export VAGRANT_DEFAULT_PROVIDER=libvirt
    

    或者修改Vagrantfile中的config.vm.provider

    vagrant-libvirt#start-vmBasic Provider Usage #Default Provider


    否则,如果您不想使用libvirtvirtualbox,则必须安装rhel box for virtualbox

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-25
      • 2012-03-30
      • 1970-01-01
      • 2017-08-18
      • 2023-03-17
      • 1970-01-01
      相关资源
      最近更新 更多