LoginSignup
14
4

More than 3 years have passed since last update.

Homebrew, rbenv インストール時のエラー解決方法

Last updated at Posted at 2021-03-05

この記事で書くこと

Homebrew, rbenv をインストールした際に発生したエラーとその解決方法。

初めに結論

rbenvのインストールに失敗した場合、その前段のHomebrewのインストールが正常に完了しているかどうかを

zsh
brew doctor

で調べて、正常完了していないようなら、その指示に従う。
今回の例では、下記を実行することで解決。

zsh
git -C $(brew --repo homebrew/core) checkout master

環境

macOS Catalina 10.15.7
MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)
2GHz クアッドコアIntel Core i5
16GB 3733 MHz LPDDR4X

ターミナル 2.10(433)

エラー発生までの過程

Progateの記事 Rubyの開発環境を用意しよう! に沿って、Ruby環境を構築しようとした。

1. 必要なツールの用意
2. Rubyを実行してみよう
3. Homebrewのインストール

ここまでは何事もなく完了(したとこの時は思っていた)。

4. rbenvのインストール

上記4.を実施時に下記のようなエラーが発生。

zsh
~ % brew install rbenv ruby-build
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
######################################################################### 100.0%
==> Pouring portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
==> Tapping homebrew/cask
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask'...
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 552725 (delta 4), reused 3 (delta 2), pack-reused 552713
Receiving objects: 100% (552725/552725), 243.99 MiB | 7.40 MiB/s, done.
Resolving deltas: 100% (390328/390328), done.
Tapped 3847 casks (3,963 files, 261.7MB).
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "rbenv".
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

エラー解決までの過程

Errorと書いている行をコピペしてGoogle先生に問合せ。

まずは、

zsh
Error: No similarly named formulae found.

先生からの回答(私が理解できる回答)はありません。次に、、、

zsh
Error: No available formula or cask with the name "rbenv".

やはり先生から回答ありません。次に、、、

いやちょっと待て。めんどい。別の視点で原因調査。

そもそも、rbenvのインストールの前に実施していた、Homebrewのインストールが本当に正常に完了しているのか?と疑ってみる。

Progateでは、

以下のコマンドを実行してください。
brew -v
Homebrew 1.6.2 のような文字が表示されれば、Homebrewは正常にインストールできています!

と記載があって、実際に自分の環境でも下のようにHomebrewのバージョン名が記載されていたので正常にインストールできているものと思っていた。

zsh
~ % brew -v
Homebrew 3.0.4-38-g61427d6
Homebrew/homebrew-core (no Git repository)

が、しかーし。
Progateで指定されていた、

Homebrewをインストールするには、以下のコマンドをコピーしてターミナルで実行します。
※ 複数行で表示していますが全部で1行のコマンドですので、全てコピーして実行してください。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

を実行した後に表示されている長い長い文字列を追っていくと、最後の方に何やら怪しげな文字列が。
error、fatal。。。

zsh
HEAD is now at 61427d668 Merge pull request #10770 from SeekingMeaning/unless_logical_operators
==> Tapping homebrew/core
remote: Enumerating objects: 64, done.
remote: Counting objects: 100% (64/64), done.
remote: Compressing objects: 100% (45/45), done.
error: RPC failed; curl 56 LibreSSL SSL_read: error:06FFF064:digital envelope routines:CRYPTO_internal:bad decrypt, errno 0
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
Failed during: git fetch --force origin refs/heads/master:refs/remotes/origin/master

やっぱり上手くインストールされていない可能性が高いw

ということで、Homebrewが正常にインストールされているのかどうかを調べる方法を検索。

Google先生、ヨロシクオネガイシマス
.
.
.
ありました!

zsh
brew doctor

とやらを実行すれば良いみたいです。

はい、ということで上記コマンドを実行してみましょう。

zsh
local % brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some taps are not on the default git origin branch and may not receive
updates. If this is a surprise to you, check out the default branch with:
  git -C $(brew --repo homebrew/core) checkout master

うーん。初心者のワタシには良く分からんが、デフォルトのブランチから引っ張って来い、ということなのか?

ようやく解決方法

まぁとにかく、一番下の行に書いてある文字列をコピペしましょうか。
全然どうでもいいが、"コピペ" って全然キー入力慣れない。。

zsh
local % git -C $(brew --repo homebrew/core) checkout master
Updating files: 100% (5792/5792), done.
Branch 'master' set up to track remote branch 'master' from 'origin'.
Already on 'master'

お、なんか上手くいったような感じ。

Homebrewのバージョンを再度確認。。

zsh
local % brew -v
Homebrew 3.0.4
Homebrew/homebrew-core (git revision c8f8f; last commit 2021-03-05)
Homebrew/homebrew-cask (git revision b5f8a9e; last commit 2021-03-05)

さっきと表記が変わりました!正常にインストールされているようです。

ということで、おそらくもうrbenvを正常にインストールするための前準備は整ったんでしょうな。

Progateの指示に再度従って。。

以下のコマンドをターミナルで実行して、rbenvをインストールしましょう。
brew install rbenv ruby-build

zsh
local % brew install rbenv ruby-build
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> Updated Casks
Updated 1 cask.

==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.catalina.bottle.4.tar.
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/ca510b350e941fb9395522a03f9d2f
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.2_3.catalina.bottle.
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/80f141e695f73bd058fd82e9f539dc
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/readline-8.1.catalina.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/fe4de019cf549376a7743dcb0c86db
######################################################################## 100.0%
==> Downloading https://github.com/rbenv/ruby-build/archive/v20210119.tar.gz
==> Downloading from https://codeload.github.com/rbenv/ruby-build/tar.gz/v20210119
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/rbenv-1.1.2.catalina.bottle.tar.gz
######################################################################## 100.0%
==> Installing dependencies for rbenv: autoconf, pkg-config, readline and ruby-build
==> Installing rbenv dependency: autoconf
==> Pouring autoconf-2.69.catalina.bottle.4.tar.gz
🍺  /usr/local/Cellar/autoconf/2.69: 67 files, 3.0MB
==> Installing rbenv dependency: pkg-config
==> Pouring pkg-config-0.29.2_3.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/pkg-config/0.29.2_3: 11 files, 623.8KB
==> Installing rbenv dependency: readline
==> Pouring readline-8.1.catalina.bottle.tar.gz
==> Caveats
readline is keg-only, which means it was not symlinked into /usr/local,
because macOS provides BSD libedit.

For compilers to find readline you may need to set:
  export LDFLAGS="-L/usr/local/opt/readline/lib"
  export CPPFLAGS="-I/usr/local/opt/readline/include"

For pkg-config to find readline you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"

==> Summary
🍺  /usr/local/Cellar/readline/8.1: 48 files, 1.6MB
==> Installing rbenv dependency: ruby-build
==> ./install.sh
==> Caveats
ruby-build installs a non-Homebrew OpenSSL for each Ruby version installed and these are never upgraded.

To link Rubies to Homebrew's OpenSSL 1.1 (which is upgraded) add the following
to your ~/.zshrc:
  export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"

Note: this may interfere with building old versions of Ruby (e.g <2.4) that use
OpenSSL <1.1.
==> Summary
🍺  /usr/local/Cellar/ruby-build/20210119: 520 files, 259.9KB, built in 4 seconds
==> Installing rbenv
==> Pouring rbenv-1.1.2.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/rbenv/1.1.2: 36 files, 69KB
==> Caveats
==> readline
readline is keg-only, which means it was not symlinked into /usr/local,
because macOS provides BSD libedit.

For compilers to find readline you may need to set:
  export LDFLAGS="-L/usr/local/opt/readline/lib"
  export CPPFLAGS="-I/usr/local/opt/readline/include"

For pkg-config to find readline you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"

==> ruby-build
ruby-build installs a non-Homebrew OpenSSL for each Ruby version installed and these are never upgraded.

To link Rubies to Homebrew's OpenSSL 1.1 (which is upgraded) add the following
to your ~/.zshrc:
  export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"

Note: this may interfere with building old versions of Ruby (e.g <2.4) that use
OpenSSL <1.1.

長いですね〜。。
ほんでもって、ビールの絵文字🍺どんだけ出てくるんよw

あ、バージョン確認しましょう。

zsh
local % rbenv -v
rbenv 1.1.2

rbenvのインストール正常にできたようです!

あ、そう言えば忘れていました。一応これやっときましょうか。

zsh
local % brew doctor
Your system is ready to brew.

こちらもOKのようです。
長かった。。

最後に

初めてQiitaに投稿しましたが、めちゃくちゃ時間かかった。
もう朝やんw

定期的に書いている人尊敬する。

マークダウン記法とやらに慣れたらもっと早く書けるんでしょうな。

macのターミナルとやらもほぼ初めて状態であんまり良く分かっていない。
諸先輩方のQiita記事(例えばコレ)を見ていると、

$ brew install zsh

のように、$から始まっているんですけど、、、
ワタシのは%ですね。。

おいおい学習していきますか。。1

あと最後に、シングルクォーテーションが下のように使われていると、その後の文字列みんな青いんですけど。
どうしたらいいんでしょw
image.png


  1. 2021/3/9 追記 $% について、bashでは $、zshでは % がデフォルトになっている模様。 

14
4
1

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
14
4