0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Dockerによるrails環境構築の際につまずいたこと

Last updated at Posted at 2025-03-04

問題

以下の記事を参考に環境構築をした際、service内のファイルを Windows 上の VS Code で保存しようとした際に、権限 (EPERM: operation not permitted) の問題が発生しました

1. service ディレクトリの所有者とパーミッションを確認
まず、所有者と権限を確認します。
ls -ld ~/environment/service
ls -l ~/environment/service

出力を確認し、自分が所有者 (owner) になっているかを確認してください。
もし root など別のユーザーになっている場合、次の手順で変更が必要です。

2. service の所有者を変更
もし service の所有者が root などになっていた場合、以下のコマンドで自分に変更できます。
sudo chown -R ユーザー名:ユーザー名 ~/environment/hello_app

-R オプションをつけることで、hello_app 内のすべてのファイルの所有者を変更します。

3. service のパーミッションを変更
所有者を変更してもアクセスできない場合、パーミッションを適切に設定します。
sudo chmod -R 755 ~/environment/service

この設定では、所有者が読み書き・実行でき、他のユーザーは読み取りと実行のみ可能になります。
もし書き込み権限も必要なら、以下のように変更できます。

sudo chmod -R 775 ~/environment/service
4. sudo でアクセスできるか確認
もし、所有者変更やパーミッション変更ができない場合、sudo を使ってアクセスできるか確認します。
sudo ls -l ~/environment/service

このコマンドでファイルが表示される場合、権限の問題が確定しますので、上記の chown や chmod で修正してください。

5. Cloud9 環境の問題の可能性
もし AWS Cloud9 などのクラウド環境を使用していて、上記の変更が反映されない場合、Cloud9 の設定によって制限されている可能性があります。 その場合は、Cloud9 のターミナルを再起動するか、Cloud9 の設定を確認してください。

まとめ

1. ls -ld ~/environment/service で所有者・権限を確認

2. sudo chown -R ユーザー名:ユーザー名 ~/environment/service で所有者を変更

3. sudo chmod -R 755 ~/environment/service で適切なパーミッションを設定

4. sudo ls -l ~/environment/service でアクセス可能か確認

5. 必要なら Cloud9 の設定やターミナルを再起動

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?