You don't have write permissions into the /var/lib/gems/1.9.1 directory
According the question I see a few steps in order to allow writing to /var/lib/gems
:
Create
gems
(if not any) group, and add yourself to the group:$ groupadd -f gems
$ usermod -aG gems $(whoami)When reenter to the session:
$ sudo -u $(whoami) bash
Allow write for a
gems
group to/var/lib/gems/
, and set thesetgid
bits:$ chown :gems /var/lib/gems/
$ chmod g+sw /var/lib/gems/Try installing gems into
/var/lib/gems/
.
NOTE: I strongly advice you to control rubies and gems via rbenv/rvm keeping them in a local home folder. Please refer to the answer to know how to properly setup your project.
You don't have write permissions for the /var/lib/gems/2.3.0 directory
You first need to uninstall the ruby installed by Ubuntu with something like sudo apt-get remove ruby
.
Then reinstall ruby using rbenv and ruby-build according to their docs:
cd $HOME
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev libffi-dev
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 2.3.1
rbenv global 2.3.1
ruby -v
The last step is to install Bundler:
gem install bundler
rbenv rehash
How to install a gem or update RubyGems if it fails with a permissions error
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
means exactly that, you don't have permission to write there.
That is the version of Ruby installed by Apple, for their own use. While it's OK to make minor modifications to that if you know what you're doing, because you are not sure about the permissions problem, I'd say it's not a good idea to continue along that track.
Instead, I'll strongly suggest you look into using either rbenv or RVM to manage a separate Ruby, installed into a sandbox in your home directory, that you can modify/fold/spindle/change without worrying about messing up the system Ruby.
Between the two, I use rbenv, though I used RVM a lot in the past. rbenv takes a more "hands-off" approach to managing your Ruby installation. RVM has a lot of features and is very powerful, but, as a result is more intrusive. In either case, READ the installation documentation for them a couple times before starting to install whichever you pick.
Unable to install rails. error: You don't have write permissions for the /usr/local/rvm/gems/ruby-2.6.3 directory
That's because at some point you used sudo
to install your rvm. So, the system will require sudo
permission to install later gems
When you use command $ sudo gem install rails -v 6.0.2.1
, you tell system to use normal directly installed ruby, not via rvm
, so it warns you No such /user/bin/gem
error
The solution for this is to change ownership of all files in the ~/.rvm
directory to current account, as if you're using root
account by following command
sudo chown -R $USER ~/.rvm
RVM gem permissions error
You missed to use ruby, you can do it with:
rvm use 1.9.3 --install
In case 1.9.3 was not installed, this command will also install it!
It also looks you are using Ubuntu, make sure you are not using RVM from Ubuntu package - that thing is broken! You can find instruction how to fix it here: https://stackoverflow.com/a/9056395/497756
You don't have write permissions for the /usr/bin directory. while installing Cocoapods
Try this, It worked for me
sudo gem install cocoapods -n /usr/local/bin
This answer has information on why /usr/bin
is protected.
Related Topics
How to Destroy a Record Without an Id Column in Ruby Activerecord
Rails - Aciverecord Use :Dependent => :Destroy on Condition
Ruby 1.9.2 - Read and Parse a Remote CSV
How to 'Unload' ('Un-Require') a Ruby Library
Rails Initializes Extremely Slow on Ruby 1.9.1
Sidekiq Worker Not Getting Triggered
How to Fix a Slow Implicit Query on Pg_Attribute Table in Rails
Expected #Count to Have Changed by 1, But Was Not Given a Block
How Can One Set Property Values When Initializing an Object in Ruby
Run a Command Line with Custom Environment
Write Array of Radix-2 Numeric Strings to Binary File in Ruby
How to Convert a Scientific Notation String to Decimal Notation
Convert Array-Of-Hashes to a Hash-Of-Hashes, Indexed by an Attribute of the Hashes
Ruby: How to Check If a String Contains Multiple Items
How to Set Ca-Bundle Path for Openssl in Ruby
How to Convert Utf8 Combined Characters into Single Utf8 Characters in Ruby