我有一个 vagrant 文件,它在执行 vagrant up 时抛出错误

I have a vagrant file which is throwing an error on executing vagrant up

我刚开始使用 vagrantfile。我创建了包含以下内容的示例文件:

Vagrant.configure("2") do |config|
  config.vm.box = "chenhan/ubuntu-desktop-20.04"
  config.vm.provider :virtualbox do |v|
   v.memory  = 8096
   v.cpus    = 4
   v.customize ["modifyvm", :id, "--vram", "128mb"]
end
end

在执行 vagrant up 命令时,报错

PS C:\Users\Anvay\Documents\Vagrant\ubuntu2004> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'chenhan/ubuntu-desktop-20.04' version '20200424' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
A customization command failed:

["modifyvm", :id, "--vram", "128mb"]

The following error was experienced:

#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["modifyvm", "7b4c021b-b083-4c05-a194-c07d22f04ab4", "--vram", "128mb"]

Stderr: Oracle VM VirtualBox Command Line Management Interface Version 6.1.34
(C) 2005-2022 Oracle Corporation
All rights reserved.

我是这个 VagrantFile 的新手,我无法理解这背后的原因。

您只需要值,它假定已经以 mb 为单位,来自 docs[--vram <vramsize in MB>]

Vagrant.configure("2") do |config|
  config.vm.box = "chenhan/ubuntu-desktop-20.04"
  config.vm.provider :virtualbox do |v|
   v.memory  = 8096
   v.cpus    = 4
   v.customize ["modifyvm", :id, "--vram", "128"]
  end
end