5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

「Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!」の解決方法

Last updated at Posted at 2021-12-18

はじめに

M1 Pro搭載Macで brew install java をしたところ、エラーが出ました。

環境

  • macOS Monterey 12.0.1
  • Homebrew 3.3.8

問題

ターミナルをRosettaを使用して開き、Homebrewでjavaをインストールしようとしたところ、エラーが出ました。
スクリーンショット 2021-12-18 10.07.13.png

解決方法

いくつか方法があるようですが、
arch -arm64 これを前に付けたら簡単に解決できました。

arch -arm64 brew install java 最終的にこれだけでOKでした。

おまけ

javaは入れられたけど、java --version でまだエラーが。

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

その場合は、
sudo ln -sfn $(brew --prefix)/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
でシンボリックリンクを貼ることで解決できました。

参考記事

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?