Vagrant 在错误的目录中寻找 Java

Vagrant looking for Java in the wrong directory

我是 运行 使用 Vagrant 的虚拟机。当我尝试启动(配置)VM 时,它一直给我以下错误:

==> default: The following packages have unmet dependencies:
==> default:  openjdk-8-jdk : Depends: openjdk-8-jre (= 8u141-b15-2~14.04) but it is not going to be installed
==> default:                  Depends: openjdk-8-jdk-headless (= 8u141-b15-2~14.04) but it is not going to be installed
==> default: E: Unable to correct problems, you have held broken packages.
==> default: update-java-alternatives: directory does not exist: /usr/lib/jvm/java-1.8.0-openjdk-amd64
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

这是什么意思,因为我的机器上有 Java 1.8。在

/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home

我通过 运行 终端 $ /usr/libexec/java_home -v 1.8

中的命令找到的

我该如何解决这个问题?

问题不是因为它在错误的目录中查找。 Vagrant 正在尝试安装 OpenJdk8,但由于某种原因它无法安装 openjdk 依赖项(apt-get 问题)。我知道这是因为我们在 2 小时前开始遇到同样的问题。

当 运行 使用 CodeBuild 在 AWS 上自动构建时,我们遇到了完全相同的问题:

The following packages have unmet dependencies:
openjdk-8-jdk : Depends: openjdk-8-jre (= 8u141-b15-2~14.04) but it is not going to be installed
Depends: openjdk-8-jdk-headless (= 8u141-b15-2~14.04) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

这是 buildspec.yml 我们 运行:

的片段
  - apt-get update
  - apt-get -y install software-properties-common
  - apt-get update
  - add-apt-repository -y ppa:openjdk-r/ppa
  - apt-get update
  - apt-get -y install openjdk-8-jdk

现在正常工作。我的猜测是构建是自动推送的,需要一些时间才能完成。现在构建已经完成,一切都恢复了原样。