2
3

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 5 years have passed since last update.

gem installに失敗するときの対処法(Mac)

Posted at

はじめに

gem install {パッケージ} で様々なエラーが発生して苦戦したので、エラーの内容と解決策を共有します。

環境

  • OS:macOS Mojave 10.14.3
  • Ruby:2.6.3
  • RubyGems:3.0.3

Failed to load {.gemrcのパス} because it doesn't contain valid YAML hash エラー

不具合内容

gem install {パッケージ} で以下のエラーが発生する。

$ gem install {パッケージ}
Failed to load /Users/{ユーザー名}/.gemrc because it doesn't contain valid YAML hash

原因

空の .gemrc ファイルが存在するため。

解決策

空の .gemrc ファイルを削除する。

$ rm ~/.gemrc

Permission denied エラー

不具合内容

gem install {パッケージ} で以下のエラーが発生する。

$ gem install {パッケージ}
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ dir_s_mkdir - /Users/{ユーザー名}/.gem/specs

原因

.gem フォルダの所有者が root になっているため。
なぜ root になったかは不明。

$ cd ~
$ ls -la
…
drwxr-xr-x   3 root        {グループ}     96  8 19 18:59  .gem
…

解決策

.gem フォルダの所有者を自分に変更する。

$ sudo chown -R {ユーザー名} ~/.gem

参考リンク

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?