1

I have been trying to solve this issue during 3-4 hours but do not get any answer yet.

run : $gem install xcpretty

it shows below error:

ERROR: While executing gem ... (Errno::EACCES) Permission denied @ rb_sysopen - /Library/Ruby/Gems/2.3.0/gems/rouge-2.0.7/Gemfile

and getting ruby upgrade issue, then installed ruby newly with updated version.

run : $sudo gem install xcpretty

then it shows below error :

Fetching: rouge-2.0.7.gem (100%)

ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

then getting gem upgrade issue, and solved with upgrading gem.

tried again as well as with below command also run : sudo gem install xcpretty --verbose

even though used 'sudo chmod -R 777' also into my /usr/bin directory

But still getting :

Fetching: rouge-2.0.7.gem (100%)

ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /usr/bin directory.

Mimu Saha Tishan
  • 2,402
  • 1
  • 21
  • 40

2 Answers2

3

After a quality time research I did not get any solution but below code which I customize is working fine for me.

sudo gem install -n /usr/local/bin xcpretty
Mimu Saha Tishan
  • 2,402
  • 1
  • 21
  • 40
1

You should never use sudo to install gems, no matter how many times you see it as an accepted answer on Stack Overflow.

This "write permissions" error comes up over and over, and is due to an improperly configured Ruby environment. The safe way to install gems on a Mac with a proper Ruby development environment involves six steps at a high level:

  1. Install Homebrew (which also installs the prerequisite Apple command line tools)
  2. Install a Ruby manager (such as chruby, rbenv, asdf, RVM) - most of these can be installed with Homebrew
  3. Configure the Ruby manager by adding the appropriate lines to your shell file (~/.bash_profile or ~/.zshrc) - each manager will have instructions for doing this, and this is a typical step that people miss
  4. Restart the terminal (or open a new tab) for the shell changes to take effect - another step that is often overlooked
  5. Install a specific version of Ruby using the Ruby manager
  6. Switch to that version of Ruby using the Ruby manager

My personal preference is chruby with ruby-install. For more details and a script that can automate this whole process, check out my answer here: https://stackoverflow.com/a/54873916/928191

monfresh
  • 7,974
  • 1
  • 25
  • 22