0
0

More than 1 year has passed since last update.

rbenvインストールで詰まったこと

Last updated at Posted at 2022-05-03

こちらの記事を参考にrbenvをインストールしようとしました。
(rubyインストールはこちらを参考)

Homebrewがインストールされている状態でmacのターミナルで下記を実行しました。

$ brew update

すると、次のようなエラーが出ました。

Error: 
  homebrew-core is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
This command may take a few minutes to run due to the large size of the repository.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!

brew updateを実行するには、最初に(first run)、次のコマンドを実行する必要があるようです。

  git -C / usr / local / Homebrew / Library / Taps / homebrew / homebrew-core fetch --unshallow

実行してみた結果

git: 'usr' is not a git command. See 'git --help'.

The most similar command is
	push

うまくいきませんでした。

usrがおかしいとのことですが、これはコマンドではありません。どうやらスペースが入ってしまったことが原因のようです。

次はこれを実行

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow

これでとりあえずうまくいったようです。

改めて

brew install rbenv

またエラーが出ました。
今度は

Error: Can't create vendor-install-ruby lock in /usr/local/var/homebrew/locks!
Fix permissions by running:
  sudo chown -R $(whoami) /usr/local/var/homebrew
Error: Failed to install Homebrew Portable Ruby (and your system version is too old)!

と出ており、権限を修正しろ、と出ます。言われた通り、次を実行。

sudo chown -R $(whoami) /usr/local/var/homebrew

その後、改めて

brew install rbenv

rbenvのインストールは進んだのですが、最後の最後で

Error: The following directories are not writable by your user:
/usr/local/share/zsh
/usr/local/share/zsh/site-functions

You should change the ownership of these directories to your user.
  sudo chown -R $(whoami) /usr/local/share/zsh /usr/local/share/zsh/site-functions

And make sure that your user has write permission.
  chmod u+w /usr/local/share/zsh /usr/local/share/zsh/site-functions

まだ権限が足りないようです。

以下の2つを実行しました。

sudo chown -R $(whoami) /usr/local/share/zsh /usr/local/share/zsh/site-functions

chmod u+w /usr/local/share/zsh /usr/local/share/zsh/site-functions

そうしてその後ようやく

brew install rbenv

が実行できました。バージョンを確認してみると

rbenv --version

結果

rbenv 1.2.0

こうしてようやくrbenvがインストールできました。

0
0
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
0
0