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.
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
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:
Install Homebrew (which also installs the prerequisite Apple command line tools)
Install a Ruby manager (such as chruby, rbenv, asdf, RVM) - most of these can be installed with Homebrew
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
Restart the terminal (or open a new tab) for the shell changes to take effect - another step that is often overlooked
Install a specific version of Ruby using the Ruby manager
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
Related
I'm trying to install packetgen, a library for crafting and manipulating network packets. I followed all the instructions, and installed all the necessary libraries. However, when I ran sudo gem install packetgen
to install it on my Linux machine it raised an error:
ERROR: Error installing packetgen:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/pcaprub-0.12.4/ext/pcaprub_c
/usr/bin/ruby2.3 -r ./siteconf20181009-29130-us1azm.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.3.0/gems/pcaprub-0.12.4 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0 /pcaprub-0.12.4/gem_make.out [here][1]
I ran the command as sudo, but got the same error. Does anyone know what I'm doing wrong here? The link to installation instructions is here.
Don't use sudo gem install but rather it is highly recommended that you use a ruby version manager, probably RVM, for more reasons why, see 'sudo gem install' or 'gem install' and gem locations
Based on your error it looks like you're trying to use your system ruby which will likely have permission and/or library dependency issues. These are easily solved by using a version manager which has many advantages including the ability to use different ruby versions on the same system and not having to use sudo or root level installs of gems.
You can install RVM from here
Instructions on gem link you posted do say gem depends on sudo apt install libpcap-dev which is a system lib your gem needs to build. I assume you did that step already right?
I am facing a issue with RVM and installed ruby debian/ubuntu package.
As long as I have only installed RVM every works fine. I can use the ruby version which is provided/installed by RVM. Also if I install a gems package compass everything works fine. The RVM is installed as recommended by RVM as single user.
As soon as I install a ruby ubuntu package (which is mandatory for some other ubuntu packages and I have not a option to remove it) my RVM configuration is broken. I cannot execute anymore the compass (command not found) also trying to install it once again with
gem install compass
I am getting
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /var/lib/gems
Also
which ruby
which gem
Points to /usr/bin and not to my home?!?
Even if I have set
PATH=/home/rocky/.nvm/v0.10.38/bin:/home/rocky/.rvm/bin:...
I have no clue where to take a look since I am very new to ruby and to RVM. Hope someone can help me?
I am getting Permission denied - /var/lib/gems
/var/lib/gems is owned by root therefore you need to do:
sudo gem install compass
which ruby Points to /usr/bin and not to my home?!? Even if I have
set
This is probably because rvm is not running. Try this:
source ~/.rvm/scripts/rvm
which ruby
Note: Once rvm is loaded correctly, which ruby will point to different location and first question may no longer persist (and so do using sudo).
I am trying to install a ruby gem in My Machine using xcode where I call a shell script.
cd "/Users/Desktop/gemfolder"
gem install somegem.gem
I am getting an error like this:
While executing gem ... (Errno::EACCES)
Permission denied - /Library/Ruby/Gems/1.8
Any workaround for it I am a newbie to ruby so don't know what to do anyhelp will highly appreciated.
Being sudo might fix your problem, however when you are installing gems , its not a good idea to install them as sudo, so the preferred way of installing ruby on any machine is to install rvm (Ruby Version Manager) first and then install your ruby version.
Main advantages of having a ruby version manager are,
1 - allows you to install multiple ruby versions side by side
2 - allows you to install gems for each ruby version (via gemsets)
So to install rvm in your mac, check here
list of ruby version managers
Trying to install Ruby Gems (actually sinatra) on iMac-
Get these error messages
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory
rubygems-2.1.11 mark$ gem install sinatra
rubygems-2.1.11 mark$ ruby setup.rb
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Library/Ruby/Site/1.8/gauntlet_rubygems.rb
Any easy solutions?
Thanks!!
The easy solution is to not try to modify the version of Ruby that Apple installed for their own use.
Instead, use rbenv or RVM to install Ruby in a sandbox in your home directory where you can fold, spindle and mutilate it all you want.
If you go with RVM, take the time to read the entire installation page before beginning your install. Failure to do that is the #1 cause for problems using RVM. RBEnv on the other hand, is simpler but not as "feature-packed". Personally, I use and recommend the later.
After the latest update it appears a few of my gems have been affected and are either missing/changed.
In particular the gem 'rubocop' is giving me issues as I use atom for a text editor and I have flags popping up.
"Failed to spawn command rubocop. Make sure rubocop is installed and on your PATH"
"Error: spawn rubocop ENOENT"
I've tried re-installing the rubocop gem through the command line and I'm running into this issue:
gem install rubocop
Fetching: rainbow-2.1.0.gem (100%)
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Library/Ruby/Gems/2.0.0/rainbow-2.1.0.gem
I've even tried to uninstall the gem but there's no output after running gem uninstall rubocop
I really have no idea where to begin to resolve this and I'd love any help possible!
Make sure you add sudo before gem install rubocop
And then go to documentation of rubocop to check which version of ruby it takes to run.
You can also install rbenv.its better then rvm (they are ruby version managers your can put multiple versions of ruby on same machine using them)
if further you need help .. let me know !
happy coding
Don't forget that installing things into the system Ruby requires sudo privileges, /Library is usually restricted access.
Installing your own personal Ruby with rvm or rbenv avoids all this.