16
22

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.

railsのエラー「Errno::EACCES: Permission denied」の解決

Last updated at Posted at 2018-06-07

事象

「rails new」で新しいアプリを作成し、「bundle install」をしようとした時に発生。

環境

  • rails 5.2.0
  • rbenv 1.1.1

エラー内容

$ rails new
$ bundle install
Errno::EACCES: Permission denied @ dir_s_mkdir - /Users/Username/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-17/2.3.0-static/websocket-driver-0.6.5
An error occurred while installing websocket-driver (0.6.5), and Bundler cannot continue.
Make sure that `gem install websocket-driver -v '0.6.5' --source 'https://rubygems.org/'` succeeds before bundling.

解決策

①エラーログに記載してあったコードをそのまま実行。

$ sudo gem install websocket-driver -v '0.6.5' --source 'https://rubygems.org/'
Password:
Building native extensions.  This could take a while...
Successfully installed websocket-driver-0.6.5
Parsing documentation for websocket-driver-0.6.5
Installing ri documentation for websocket-driver-0.6.5
Done installing documentation for websocket-driver after 1 seconds
1 gem installed

これでもインストール自体はできたのですが、その後再び同じエラーで止まってしまった。
根本的解決ではなかったため、違う方法を検討。

②/rbenv以下の権限を変更する

今回は以下のファイル権限の所有者がrootになっていたので、自分に変更。

/Users/Username/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/

$ cd /Users/Username/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0-static/
$ ls -la
total 0
drwxr-xr-x  10 Username   staff  320  6  7 23:24 .
drwxr-xr-x   3 Username   staff   96  5 11 14:46 ..
drwxr-xr-x   6 root  staff  192  6  7 22:53 bigdecimal-1.3.4
drwxr-xr-x   6 root  staff  192  6  7 22:54 io-console-0.4.6
drwxr-xr-x   6 root  staff  192  6  7 22:54 json-2.1.0
drwxr-xr-x   6 root  staff  192  5 11 14:47 nio4r-2.3.1
drwxr-xr-x   6 root  staff  192  5 11 14:47 nokogiri-1.8.2
drwxr-xr-x   6 root  staff  192  6  7 22:54 psych-3.0.2
drwxr-xr-x   5 root  staff  160  6  7 23:24 websocket-driver-0.6.5
drwxr-xr-x   5 root  staff  160  5 11 14:47 websocket-driver-0.7.0
$ sudo chown Username bigdecimal-1.3.4/
$ sudo chown Username io-console-0.4.6/
$ sudo chown Username json-2.1.0/
$ sudo chown Username nio4r-2.3.1/
$ sudo chown Username nokogiri-1.8.2/
$ sudo chown Username psych-3.0.2/
$ sudo chown Username websocket-driver-0.

(ファイル一括変更のやり方が分からなかったので個別に変更)

今回はこちらでbundle installが最後まで通ったので、解決としました。

16
22
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
16
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?