Search code examples
rubyrubygemsbundler

Getting permission denied error when I run "gem install bundler"


I'm setting up my environment to run Cucumber/Rspec with Ruby and Capybara.

However, when I run the command "sudo gem install bundler" the error below is being returned:

Permission denied @ rb_sysopen

I've seen lots of answers for this problem on Google however still not working.

Could you guys help me?

Technical info

- Mac
- ruby 2.3.7
- RUBYGEMS VERSION: 3.0.3

Output

ERROR:  While executing gem ... (Errno::EACCES)
Permission denied @ rb_sysopen - 
/Library/Ruby/Gems/2.3.0/gems/bundler-2.0.2/CHANGELOG.md

Thanks!


Solution

  • you are using the system's ruby and now you need to root level permission to to install bundler. Sudo enables root privileges. Check if your account has root privileges.

    I prefer using a version and manager like rbenv. Install rbenv . then install the required version of ruby and then install bundler.