如何修复 debconf:无法初始化前端:W/Packer 对话框错误?

Mik*_*kel 5 apt automation error-handling debconf software-installation

我使用Packer vsphere-iso构建器通过配置shell程序在 vSphere 上构建 Ubuntu-18.04 VM ,当我运行以下两个命令之一时:

sudo apt-get install software-properties-common --yes
sudo apt-get install ca-certificates curl gnupg lsb-release --yes
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

==> vsphere-iso.ubuntu-18_04-base-template: debconf: unable to initialize frontend: Dialog
==> vsphere-iso.ubuntu-18_04-base-template: debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
==> vsphere-iso.ubuntu-18_04-base-template: debconf: falling back to frontend: Readline
==> vsphere-iso.ubuntu-18_04-base-template: debconf: unable to initialize frontend: Readline
==> vsphere-iso.ubuntu-18_04-base-template: debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7, <> line 31.)
==> vsphere-iso.ubuntu-18_04-base-template: debconf: falling back to frontend: Teletype
==> vsphere-iso.ubuntu-18_04-base-template: dpkg-preconfigure: unable to re-open stdin:
Run Code Online (Sandbox Code Playgroud)

谷歌搜索这个问题,我发现很多人说设置DEBIAN_FRONTEND=noninteractive可以解决这个问题,包括这里的 Ask Ubuntu,但这并没有解决我的问题。

我知道我可以通过管道传递错误,/dev/null但我宁愿不这样做,以防发生破坏构建的错误。我想真正阻止错误的发生,例如设置DEBIAN_FRONTENDnoninteractive应该做的。

有谁知道如何解决这一问题?

小智 0

这个答案说:

echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
Run Code Online (Sandbox Code Playgroud)

另外,评论补充道:

我建议运行 debconf-show debconf 来查看默认值,以便在执行上述操作时发生问题时有助于恢复默认值。