

`$bundle install`を実行したところpermission deniedとなりgemをインストールできません。  
↓  
エラー内容

[code]

    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/............
    Fetching gem metadata from https://rubygems.org/.
    Resolving dependencies.....
    Using rake 13.0.1
    Using concurrent-ruby 1.1.5
    Using i18n 1.7.0
    Using minitest 5.13.0
    Using thread_safe 0.3.6
    Using tzinfo 1.2.5
    Using activesupport 5.2.3
    Using builder 3.2.3
    Using erubi 1.9.0
    Using mini_portile2 2.4.0
    Fetching nokogiri 1.10.5
    Errno::EACCES: Permission denied @ rb_file_s_rename -
    (/Users/username/.gem/ruby/2.6.0/cache/nokogiri-1.10.5.gem,
    /Users/username/rails/taskleaf/vendor/bundle/ruby/2.6.0/cache/nokogiri-1.10.5.gem)
    An error occurred while installing nokogiri (1.10.5), and Bundler cannot continue.
    Make sure that `gem install nokogiri -v '1.10.5' --source 'https://rubygems.org/'` succeeds before
    bundling.
    
    In Gemfile:
      rails was resolved to 5.2.3, which depends on
        actioncable was resolved to 5.2.3, which depends on
          actionpack was resolved to 5.2.3, which depends on
            actionview was resolved to 5.2.3, which depends on
              rails-dom-testing was resolved to 2.0.3, which depends on
                nokogiri
    
[/code]

エラーメッセージの記載通り、  
`gem install nokogiri -v '1.10.5' --source
'https://rubygems.org/'`を実行するもコマンド自体動きませんでした。

(<https://rubygems.org/gems/nokogiri>) にて「nokogiri」を検索  
↓  
`gem 'nokogiri', '~> 1.10', '>= 1.10.5’`をGemfileに貼り付け  
`$ gem install nokogiri` 実行  
↓

[code]

    Permission denied @ rb_sysopen - /Users/username/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.5/LICENSE-DEPENDENCIES.md
    
[/code]


CC BY-SA 4.0
2019-11-25T04:01:28.107
60816
2019-11-25T07:53:58.307
2019-11-25T04:04:48.523
3060
36775
question
ruby-on-rails
bundle installしようとしたところpermission deniedエラーになる


gemのインストールでパーミッションエラーが出る時は以前どこかで`sudo`をつけて`bundle`や`gem`の操作をしてしまったためにファイルの上書き権限がない事が原因になってる場合が多いです。

`rbenv`再インストールして`gem`も入れ直すのが一番簡単な解決方法だと思います。


CC BY-SA 4.0
2019-11-25T07:53:58.307
60822
2019-11-25T07:53:58.307
3271
60816
answer