Vagrant在错误的目录中寻找Java

时间:2017-07-25 18:35:14

标签: java macos vagrant vagrantfile

我正在使用Vagrant运行VM。当我尝试启动(配置)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

中运行命令找到的

我该如何解决这个问题?

3 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分: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

答案 2 :(得分:0)

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