Installing ruby gems Error: operation nor permitted - usr/bin/sprockets - ruby

Im trying to get rubymine to work but i always keep getting this error "operation not permitted"
Gabriellas-MBP:~ GabriellaKampe$ gem install rails
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Gabriellas-MBP:~ GabriellaKampe$ sudo gem install rails
Password:
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/sprockets
Gabriellas-MBP:~ GabriellaKampe$

You don't have permission to write to the gemfile directory of your the ruby version that comes bundled with your OS. What you'll have to do is manage your ruby versions using either rbenv or rvm. I will recommend rbenv and you can follow the guide on these links rbenv rails install Mac OS or rbenv rails install Ubuntu

Related

File permission error when installing gem bundle for ruby

This is the massage I am getting
IMTIAZs-MacBook-Pro:~ imtiazahmed$ gem install bundle ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory. IMTIAZs-MacBook-Pro:~ imtiazahmed$
Please help me to solve this.
Thanks
Im on macos big sur 11.6 I had to export ruby to my path in the terminal
export PATH="/Users/okerajohnson/.gem/ruby/2.6.0/bin:$PATH"
and even after that regularly typing gem install gem_name still gave me permission error so I have to do
gem install gem_name --user-install
Installing gem or updating RubyGems fails with permissions error

Ruby on mac not installing gem showing permission denied

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

Installing Ruby gems-permissions error

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.

Installing gem fails with permissions error [duplicate]

This question already has answers here:
How to install a gem or update RubyGems if it fails with a permissions error
(32 answers)
Closed 7 years ago.
I updated my Mac OS to 10.9 Mavericks yesterday. My current Ruby version shows as
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
I got Rails installed on my machine and when I try to install gems I get the following message:
Fetching: eventmachine-1.0.3.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
I am trying all this in my home directory. Any suggestions?
Use a Ruby version manager, like RVM or rbenv.
I can't speak for rbenv, but RVM prepends a Ruby version-specific bin to your PATH that you have access to, so you don't have to use sudo (which is how you could install gems in your current situation, but is highly discouraged).
rbenv similarly prepends to your $PATH, but it uses a shim.
When I had this same error it was because I did not have a Ruby version manager installed, it defaulted to the Ruby version that came shipped with my computer which is owned root.
Since it is a very bad idea to use sudo to install gems, I installed RVM with Ruby 2.1.2
\curl -sSL https://get.rvm.io | bash -s stable --ruby=2.1.2
then made sure that it was being used as the default by running
rvm use ruby-2.1.2
RVM creates a new location to store your Ruby and gems with your user permissions so you don't have to use sudo or get a permissions error. The new gem location is:
~/.rvm/gems
Then carry on as you were...
gem install ....
I do not have RVM installed. I got this error because I installed rbenv but did not run rbenv init yet.
After I inserted the contents from the command rbenv init into .bash_profile, gem install works as expected.
I also happened to set rbenv global <ruby-version> to a downloaded Ruby version first.
Just like to say to you all after wasting a good hour or more on trying to install RubyGems... to rubygems-2.4.5 'sudo' got me through!
It works a treat...

Error installing rubygems

I get the following error when trying to install rubygems version 1.3.7
~/Downloads/rubygems-1.3.7
$ ruby setup.rb
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem
Any idea what is cause this. I've previously installed RVM.
Thanks
Run the command
sudo !!
Rather than mess with your system installation of Ruby, consider using RVM to manage your Ruby installation(s). RVM will install multiple Rubies on demand, allow you to create various gem sets, copy them between versions of Ruby, all while sandboxing your Ruby installation in ~/.rvm.
Installing RVM

Resources