0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Rails】railsがインストールできない!時の対処法

Last updated at Posted at 2025-04-30

gem install railsが実行できない場合

以下のエラーが出てきた場合です。

% gem install rails
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Users/testuser/.rbenv/versions/3.4.3/lib/ruby/gems/3.4.0/gems/rails-8.0.2/MIT-LICENSE directory

書き込み権限がないっすよ!」って言われてますね。ってことは、書き込み権限を付与すればいいのです。エッヘン<( ̄^ ̄)>

1. gemを保存するディレクトリを作成

% mkdir -p $HOME/.gem/ruby

2. .zshrc にパスを追加

まず、.zshrcの中身を確認しておきましょう。

% vi ~/.zshrc

# または

% cat ~/.zshrc

次に、以下のコマンド二つを実行します。

% echo 'export GEM_HOME="$HOME/.gem/ruby"' >> ~/.zshrc

% echo 'export PATH="$HOME/.gem/ruby/bin:$PATH"' >> ~/.zshrc

次に、以下のコマンドを実行して、パスを反映させます。

% source ~/.zshrc

gem install rails を実行

% gem install rails
Fetching rails-8.0.2.gem
Successfully installed rails-8.0.2
Parsing documentation for rails-8.0.2
Installing ri documentation for rails-8.0.2
Done installing documentation for rails after 0 seconds
1 gem installed

できた!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?