GCP 数据存储模拟器无法安装在 OpenJDK 10 上

GCP Datastore Emulator won't install on OpenJDK 10

我有一个 Ubuntu 主机,我在上面使用 APT 安装了 OpenJDK 10 和 Gloud SDK。当我尝试安装 'google-cloud-sdk-datastore-emulator' 时,出现如下所示的错误。 我在 GCP GitHub 上找到了一个讨论此问题的线程,但它已关闭。这里 - https://github.com/GoogleCloudPlatform/cloud-sdk-docker/issues/144

还有其他人遇到这个问题吗?

错误 -

# apt install google-cloud-sdk-datastore-emulator
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 google-cloud-sdk-datastore-emulator : Depends: openjdk-8-jdk but it is not installable
E: Unable to correct problems, you have held broken packages.

我的环境 -

OS -

DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"

OpenJDK -

#java -version
openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)
#javac -version
javac 10.0.2
#which java
/usr/bin/java

Gcloud SDK -

# gcloud -v
Google Cloud SDK 234.0.0
alpha 2019.02.08
beta 2019.02.08
bq 2.0.41
core 2019.02.08
gsutil 4.36
kubectl 2019.02.08

我们的 debian 软件包依赖配置存在一些问题。 尽管如果您通过 gcloud 命令安装模拟器,它应该可以工作:

gcloud components install cloud-datastore-emulator

(https://cloud.google.com/sdk/gcloud/reference/components/install)

请注意,如果从其他包管理器安装 sdk,组件管理器将不起作用。在这种情况下,您可以将其删除并按照此处的建议进行安装:Whosebug。com/questions/42697026

如果由于某些其他原因您必须通过 apt-get 安装,https://serverfault.com/questions/250224 应该会有所帮助,基本上避免安装 openjdk by:

apt-get install google-cloud-sdk-datastore-emulator openjdk-8-jdk-

注意打开后有个“-”jdk-8-jdk

或者您可以按照同一线程中的步骤更新包依赖性。

我的解决方案涉及使用 equivs 创建一个假的 openjdk-8-jdk 包(当然你需要确保你有另一个 JDK) .

apt-get install equivs
equivs-control openjdk-8-jdk
vim openjdk-8-jdk # especially change the package name, but I also used 11.0.0 as a version (although it's probably not needed)
equivs-build openjdk-8-jdk
dpkg -i openjdk-8-jdk*.deb