简体   繁体   English

在 M1 macOS 上安装 Hive

[英]Installing Hive on M1 macOs

When I tried to install Hive through homebrew it throws below error:当我尝试通过自制软件安装 Hive 时,它会抛出以下错误:

homebrew install hive
Error: openjdk@8: no bottle available!

Has anyone solved this issue?有没有人解决过这个问题? I did a bit of research in google and someone said "this is because the M1 chip needs it's own special version of OpenJDK ".我在谷歌做了一些研究,有人说“这是因为 M1 芯片需要它自己的特殊版本的 OpenJDK”。

Finally, I found a solution.最后,我找到了解决方案。 First, We need to install Homebrew with Rosetta under /usr/local and then we can try installing everything the same way.首先,我们需要在 /usr/local 下使用 Rosetta 安装 Homebrew,然后我们可以尝试以相同的方式安装所有内容。

Apple silicone M1 and similar processors have the ARMv8.4 architecture and rosetta2 to launch native amd64 binaries on the arm64 processor. Apple Silicon M1 和类似处理器具有ARMv8.4架构和rosetta2 ,可在 arm64 处理器上启动本机 amd64 二进制文件。 So apple silicone may launch nearly any app compiled for the Intel platform (there is some exception, for example, the older version of PostgreSQL won't be launched by rosetta2).所以苹果硅胶可能会启动几乎所有为英特尔平台编译的应用程序(有一些例外,例如,旧版本的 PostgreSQL 不会被 Rosetta2 启动)。

By default, homebrew detects the platform that is installed and tries to find the bottle that is appropriate for arm64.默认情况下, homebrew会检测安装的平台并尝试找到适合 arm64 的瓶子。 In some cases, there is no bottle for some applications (for example, you can't install openjdk@8 on arm64 because there is no bottle).在某些情况下,某些应用程序是没有瓶子的(例如,您无法在 arm64 上安装openjdk@8 ,因为没有瓶子)。 But you can install, for example, oracle JDK because there is the bottle for arm64 (but it will install amd64 binaries).但是您可以安装,例如 oracle JDK,因为有 arm64 的瓶子(但它会安装 amd64 二进制文件)。 It is a pretty confusing situation, isn't it?这是一个相当混乱的情况,不是吗?

The decision is to install the second copy of homebrew into the /usr/local/homebrew directory and launch it in compatibility mode with the command arch -x86_64 .决定是将 homebrew 的第二个副本安装到/usr/local/homebrew目录中,并使用命令arch -x86_64以兼容模式启动它。 You won't start the original homebrew with this command because it will lid to mix arm64 and amd64 binaries (and what you will do, if you need the same library for both platforms? libpq as an example).您不会使用此命令启动原始homebrew ,因为它会混合 arm64 和 amd64 二进制文件(如果您需要为两个平台使用相同的库,您将做什么?以 libpq 为例)。

So there is the step-by-step guide:所以有一步一步的指南:

  1. Download homebrew curl -L https://github.com/Homebrew/brew/tarball/master --output homebrew.tar下载自制软件curl -L https://github.com/Homebrew/brew/tarball/master --output homebrew.tar
  2. Extract tarball to /usr/local/homebrew解压压缩包到/usr/local/homebrew
  3. chown -R to allow start apps from this folder chown -R 允许从此文件夹启动应用程序
  4. Add aliases to your ~/.zshrc file为您的 ~/.zshrc 文件添加别名
# If you come from bash you might have to change your $PATH. # need this for x86_64 brew export PATH=$HOME/bin:/usr/local/bin:$PATH # for intel x86_64 brew alias axbrew='arch -x86_64 /usr/local/homebrew/bin/brew'
  1. Now start new console and launch installation, for example axbrew install openjdk@8现在启动新控制台并启动安装,例如axbrew install openjdk@8

Install other Intel binaries you need the same way.以相同的方式安装您需要的其他英特尔二进制文件。 Remember that it will be installed into the /usr/local/homebrew/ directory - fill free to create a symlink if you wanna use it something else.请记住,它将被安装到/usr/local/homebrew/目录中 - 如果您想使用其他东西,请随意填写以创建符号链接。 The slight disadvantage - the java_version tool won't see the OpenJDK in /user/local directory , but symlink to /Library/Java/JavaVirtualMachines/ will solve this problem.轻微的缺点 - java_version工具不会在/user/local directory中看到 OpenJDK,但是到/Library/Java/JavaVirtualMachines/的符号链接将解决这个问题。

Combine Gleb Yan's answer and another website's solution https://github.com/Homebrew/discussions/discussions/2723 .结合 Gleb Yan 的答案和另一个网站的解决方案https://github.com/Homebrew/discussions/discussions/2723 What I do is我所做的是

arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then run然后运行

arch -x86_64 /usr/local/homebrew/bin/brew install openjdk@8

Then然后

arch -x86_64 /usr/local/homebrew/bin/brew install hive

Reminder two separate Homebrew hierarchies on your machine, an Intel-only one under /usr/local, and an M1-only one under /opt/homebrew提醒您机器上的两个单独的 Homebrew 层次结构,一个在 /usr/local 下仅适用于 Intel,在 /opt/homebrew 下仅适用于 M1

This link could be a good resource in order to fully understand the answers.这个链接可能是一个很好的资源,可以完全理解答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM