[Environment construction] Error when bundle install Errno :: EACCES: Permission denied @ dir_s_mkdir-

Introduction

It is difficult to grasp the cause of the environment construction error, and if you change the setting by mistake, you will likely enter a labyrinth. This article is the process of resolving the error that occurred when trying to bundle install.

However, the error varies depending on the circumstances and environment leading up to the error. Please use this article as a reference only.

error

Errno::EACCES: Permission denied @ dir_s_mkdir -

In particular, I think there are various ways to resolve this error depending on the situation, but in my case the problem was the setting of "permissions".

Conclusion

I was able to solve it by changing the authority with the following command.

sudo chown -R [username] /Users/[username]/.rbenv  
Password: (Enter password)

environment

macOS Catalina version 10.15.7 Homebrew 2.7.1 rbenv 1.1.2 ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19] gem 3.2.4 Bundler version 2.1.4

Error details

When I did bundle install, I got the following error.

Errno::EACCES: Permission denied @ dir_s_mkdir -
/Users/[username]/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/bindex-0.8.1
An error occurred while installing bindex (0.8.1), and Bundler cannot
continue.
Make sure that `gem install bindex -v '0.8.1' --source 'https://rubygems.org/'`
succeeds before bundling.

I paid attention to the following two.

Errno::EACCES: Permission denied @ dir_s_mkdir - /Users/[username]/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/bindex-0.8.1

File access is denied.

Make sure that gem install bindex -v '0.8.1'

Please check the gem bindex.

Upon examination, it seems that the cause was that you did not have permission to access this file, and there were two conclusions and countermeasures.

  1. Force it with the sodu command.
  2. Change the authority settings.

Apparently the permissions setting was changed to root and it seemed that I had to change this to[username]. I haven't changed the permissions, but it seems that the settings change even when I use the sudo command.

Considering the future, I decided to change the authority setting.

What went

First, I investigated what the authority was. You can check it with the ls -al command, but you can find out the status of the specified file by writing the file name after it.

It was said that Make sure that gem install bindex -v '0.8.1', so I checked the surrounding files.

ls -al /Users/[username]/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/           
total 0
drwxr-xr-x  6 root  staff  192 Dec 30 07:24 .
drwxr-xr-x  3 root  staff   96 Dec 29 16:31 ..
drwxr-xr-x  5 root  staff  160 Dec 30 07:24 bcrypt-3.1.16
drwxr-xr-x  6 root  staff  192 Dec 29 16:32 nio4r-2.5.4
drwxr-xr-x  6 root  staff  192 Dec 29 16:32 nokogiri-1.10.10
drwxr-xr-x  5 root  staff  160 Dec 29 16:32 websocket-driver-0.7.3

I'm sure I'm root.

You can change the authority with the following command. I'm using .rbenv, so I decided to change the whole subordinate.

sudo chown -R [username] /Users/[username]/.rbenv  
Password: (Enter password)

Check with the ls -al command.

ls -al /Users/[username]/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/
total 0
drwxr-xr-x  6 [username]  staff  192 Dec 30 07:24 .
drwxr-xr-x  3 [username]  staff   96 Dec 29 16:31 ..
drwxr-xr-x  5 [username]  staff  160 Dec 30 07:24 bcrypt-3.1.16
drwxr-xr-x  6 [username]  staff  192 Dec 29 16:32 nio4r-2.5.4
drwxr-xr-x  6 [username]  staff  192 Dec 29 16:32 nokogiri-1.10.10
drwxr-xr-x  5 [username]  staff  160 Dec 29 16:32 websocket-driver-0.7.3

It has been changed.

Do a bundle install.

bundle install

The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/............
.
.
.~abridgement~
.
.
Bundle complete! 26 Gemfile dependencies, 92 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

The usual reading started and it was solved safely! !!

Finally

I hope it helps people who are suffering from errors as well.

reference

https://dara-blog.com/about-rails-error01

https://qiita.com/Ryosci/items/e364e181ced7fbd5e239

Recommended Posts

[Environment construction] Error when bundle install Errno :: EACCES: Permission denied @ dir_s_mkdir-
Error when bundle install
bundle install error
bundle install error
I got a Permission Denied error when I put Laravel in Docker
Error when npm install on Windows 7
Error summary in bundle install. memorandum
When building rails6 environment on Ubuntu, it gets stuck with bundle install