My ultimate goal is to install Sass.
To do this I need to install RubyGems
To do this I need to install Ruby.
I installed Ruby with yum.
I then tried to install gem with yum yum install rubygem
The response is "nothing to do" and yet when I write gem install sass I get:
gem: command not found
I decided to try to install rubygems 2.2.2 manually. After downloading it, I tried to run ruby setup.rb and in response I get:
Rubygems now requires Ruby 1.8.7 or later
But yum does not seem to be able to install anything later than 1.8.5.
So now I'm trying to do this manually.
I downloaded Ruby 1.9.2 to my home directory and followed these instructions: http://howboring.com/post/1226760251/centos-5-and-rails-3-and-ruby-1-9-2
This seems to work, but the problem is ruby1.9.2 is installed in my home directory (i.e. ~/ruby1.9.3 not system wide.
Thus in the directory where I installed ruby 1.9.2 ruby -v still gives 1.8.5 but ./ruby -v returns 1.9.2. And which ruby returns /usr/bin/ruby (I suppose I could replace this with a symlink that points to ~/ruby1.9.2/ruby but this doesn't seem like a "best practice")
So my main question is where should install ruby 1.9.2 with Root Permissions so that 1.8.5 is replaced with 1.9.2 system wide.
My corollary question is: is there any easier way to do this? (perhaps install sass without install rubygems??)
I then tried to install gem with yum yum install rubygem
You have a typo in the package name, it is actually named rubygems.
Can i suggest Wayne Seguins excellent rvm (ruby version manager). As the home page states:
"RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems".
Site has comprehensive installation instructions. I've posted a truncated Set of instructions for installing on POSIX systems below, but please refer to the projects' home page as:
"we have spent massive amounts of man hours debugging the installation process. Please use the install process(es) from this site only, as this is the only supported installation types and methods."
Install RVM (development version):
\curl -sSL https://get.rvm.io | bash
Close out your current shell or terminal session and open a new one (preferred). You may load RVM with the following command:
user$ source ~/.rvm/scripts/rvm
test the installation was successful:
user$ type rvm | head -n 1
this should output "rvm is a function"
List all known rubies:
rvm list known //this will output a large list of rubies shortened here
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p545]
[ruby-]2.0.0-p353
[ruby-]2.0.0[-p451]
[ruby-]2.1[.1]
[ruby-]2.1-head
ruby-head
...
install the version you want:
rvm install 1.9.2
You can set a version of Ruby to use as the default for new shells. Note that this overrides the 'system' ruby:
rvm use 2.1 --default
You can also temporarily use another version of your ruby versions
rvm list known //lists system available rubies
Choose to use another ruby
rvm use 1.9.3
RVM is a great tool, well documented, and actively developed, it handles a wider scope of functionality than i can list here, and it's a tool I use everyday.
You can use rbenv to install ruby and rubygems that you need
https://gist.github.com/jpfuentes2/2002954
I uninstalled RVM and re-installed using a single user installation using:
\curl -L https://get.rvm.io | bash -s stable
When I do bundle, it prompts for:
Enter your password to install the bundled RubyGems to your system:
I tried using the answer in "ERROR: While executing gem … (Gem::FilePermissionError)" which did not fix it.
Then, while trying to install the gem manually, I got:
Gem::InstallError: nokogiri requires Ruby version >= 1.9.2.
An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.
then running gem install nokogiri -v '1.6.0' returned:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.
I checked all the similar posts on SO, but they didn't solve the problem. What am I missing?
I spent a lot of time fixing this issue on my MacBook. The gem update --system does not work for me.
At last, putting the following code in the ~/.zshrc file and create a new zsh session works for me.
export GEM_HOME="$HOME/.gem"
export GEM_PATH="$HOME/.gem"
after you install RVM you still need few more steps:
Load RVM to the current shell:
source ~/.rvm/scripts/rvm
Usually this would not be needed if you close and open your terminal again
Install ruby:
rvm install ruby
Use ruby:
rvm use ruby
The last step is very important as your error message mentioned system ruby not the one controlled by RVM.
Make sure to update your system rubygems with this command : sudo gem update --system --no-user-install.
bundler use it instead your local version and your bundler version could be incompatible with your system rubygems.
It works for me ;)
I feel like a compelte idiot, but I've been wrking on this all day and getting no where.
I've restarted several times trying to get a full install of Ruby on my OSX environment, RVM, Brew, Ruby: and every time I get through to the Ruby install it bottoms out on the rubygems install.
The reason I'm having to start again is that the RVM wouldn't update in Jewelerybox after my first successfull install (used a packaged all-in-one RubyInstaller) so I couldn't manage my gems - a problem caused by the initial Ruby install on the system living in the /usr/local and not under my own directory. To fix this I uninstalled all my Ruby stuff and started again.
All ok until the ruby compiler started gacking on the rubygems install section when installing ruby 2.0.0. Checking out the OSX system files under usr/bin I see that rubygems isn't there either (it should be present by default on OSX). Any ideas? (note that XCode is up to date and has command line tools installed)
Last attempt was:
$ rvm get head --autolibs=3 # get the latest RVM and build required libs
$ rvm requirements # just in case, install all other required stuff
$ rvm remove 2.0.0
$ rvm install ruby-2.0.0
. . . which fires the following error:
[2013-03-19 23:21:50] /Users/matthew.evans/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
Exception `LoadError' at /Users/matthew.evans/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rubygems.rb:1073 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Users/matthew.evans/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rubygems.rb:1082 - cannot load such file -- rubygems/defaults/ruby
mkdir -p /Users/matthew.evans/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0
...
install -c -m 0755 /var/folders/nq/wkj89k854tl0w97n68qdn820pzk_51/T/gem.84634 /Users/matthew.evans/.rvm/rubies/ruby-2.0.0-p0/bin/gem
rm /var/folders/nq/wkj89k854tl0w97n68qdn820pzk_51/T/gem.84634
ERROR: While executing gem ... (NoMethodError)
undefined method `fu_stream_blksize' for #<Gem::Commands::SetupCommand:0x007ffd0e054818>
Installing RubyGems
Installing gem executable
I had the exact same error installing ruby v2 within rvm today. I was in a user account on Ubuntu who needed to use 'sudo' -- and enter my account password for sudo -- in order to install OS dependencies.
Your question mentions running rvm requirements to install dependencies. That seems to be new behavior in rvm, as of v1.19. It seemed to install a bunch of dependencies just fine. But then installing ruby bombed.
In earlier rvm versions, typing rvm requirements would just list the dependencies for rvm and for ruby, as in Archonic's answer.
I typed rvm implode and then started over with:
\curl -L https://get.rvm.io | bash -s 1.18.21
source /home/deploy/.rvm/scripts/rvm
rvm requirements
At that point I could install the libraries/tools that rvm said I needed for rvm and ruby, and then rvm install ruby-2.0.0-p0 succeeded.
I believe the issue is where RVM places your dependencies - global vs your user folder. From a book called "Agile development with rails":
First, you’ll need to make sure you have Xcode 3 or later installed...
$ xcodebuild -version
If you have Xcode version 3 installed, you’ll need to install the Git version control system separately. Verify your installation by running the following command:
$ git --version
Next, install RVM itself:
$ curl -L https://get.rvm.io | bash -s stable
Exit your command window or Terminal application and open a new one. This causes your .bash_login to be reloaded. Execute the following command, which provides additional installation instructions tailored to your specific operating system:
$ rvm requirements
Look for the line that tells you how to install the necessary OS dependencies for Ruby (MRI). Once you complete those instructions, you can proceed to install the Ruby interpreter itself:
$ rvm install 2.0.0
The preceding step will take a while as it downloads, configures, and compiles the necessary executables. Once it completes, use that environment, and install rails:
$ rvm use 2.0.0
$ gem install rails --version 4.0.0.beta1 --no-ri --no-rdoc
With the exception of the rvm use statement, each of the above instructions need only be done once. The rvm use statement needs to be repeated each time you open a shell window. The use keyword is optional, so you can abbreviate this to rvm 2.0.0. You can also choose to make it the default Ruby interpreter for new terminal sessions with the following command:
$ rvm --default 2.0.0
You can verify successful installation using the following command:
$ rails -v
If you have trouble, try the suggestions listed under the Troubleshooting Your Install heading on the rvm site.
Hope that does it for you!
This worked for me:
rvm get head
rvm requirements
rvm install ruby-2.0
I'm trying to install a gem using gem install mygem or update RubyGems using gem update --system, and it fails with this error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Does anyone have an idea how to solve this?
Try adding --user-install instead of using sudo:
gem install mygem --user-install
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.
You really should be using a Ruby version manager.
Using one properly would prevent and can resolve your permission problem when executing a gem update command.
I recommend rbenv.
However, even when you use a Ruby version manager, you may still get that same error message.
If you do, and you are using rbenv, just verify that the ~/.rbenv/shims directory is before the path for the system Ruby.
$ echo $PATH will show you the order of your load path.
If you find that your shims directory comes after your system Ruby bin directory, then edit your ~/.bashrc file and put this as your last export PATH command: export PATH=$HOME/.rbenv/shims:$PATH
$ ruby -v shows you what version of Ruby you are using
This shows that I'm currently using the system version of Ruby (usually not good)
$ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
$ rbenv global 1.9.3-p448 switches me to a newer, pre-installed version (see references below).
This shows that I'm using a newer version of Ruby (that likely won't cause the Gem::FilePermissionError)
$ ruby -v
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin12.4.0]
You typically should not need to preface a gem command with sudo. If you feel the need to do so, something is probably misconfigured.
For details about rbenv see the following:
https://github.com/sstephenson/rbenv
http://robots.thoughtbot.com/post/47273164981/using-rbenv-to-manage-rubies-and-gems
Why don't you do:
sudo gem update --system
This will fix the issue on MacOS Mojave and Catalina in a clean way:
brew install ruby
Then set GEM_HOME to your user directory. On the terminal:
Bash:
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc
echo 'export GEM_HOME=$HOME/gems' >> ~/.bashrc
echo 'export PATH=$HOME/gems/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
OR if on Zsh:
echo '# Install Ruby Gems to ~/gems' >> ~/.zshrc
echo 'export GEM_HOME=$HOME/gems' >> ~/.zshrc
echo 'export PATH=$HOME/gems/bin:$PATH' >> ~/.zshrc
source ~/.zshrc
For me the problem was due to using rbenv and forgetting to set the proper version globally.
So I had to set it with rbenv global xxx
In my case I installed 2.0.0-p247 so I had to issue the command:
rbenv global 2.0.0-p247
rbenv rehash
Then all was working fine.
You need to correct your paths.
To determine if this fix will work, run the following:
which gem
This should output a directory you do not have permissions to:
/usr/bin/gem
To fix this perform the following steps:
Determine the path you need to copy to your profile:
rbenv init -
The first line of the output is the line you need to copy over to your profile:
export PATH="/Users/justin/.rbenv/shims:${PATH}" #path that needs to be copied
source "/usr/local/Cellar/rbenv/0.4.0/libexec/../completions/rbenv.zsh"
rbenv rehash 2>/dev/null
rbenv() {
typeset command
command="$1"
if [ "$#" -gt 0 ]; then
shift
fi
case "$command" in
rehash|shell)
eval `rbenv "sh-$command" "$#"`;;
*)
command rbenv "$command" "$#";;
esac
}
Copy the path to your profile and save it.
Reload your profile (source ~/.zshenv for me).
Run rbenv rehash.
Now when you run which gem you should get a local path that you have permissions to:
/Users/justin/.rbenv/shims/gem
This worked for me. Plus, if you installed gems as root before, it fixes that problem by changing ownership back to you (better security-wise).
sudo chown -R `whoami` /Library/Ruby/Gems
Try nathanwhy's answer before using my original answer below. His recommendation of --user-install should accomplish the same purpose without having to muck with your .bash_profile or determine your Ruby version.
If you are not concerned about a specific ruby version, you can skip the heavy-lift Ruby environment manager options, and just add these lines to ~/.bash_profile:
export GEM_HOME="$HOME/.gem/ruby/2.0.0"
export GEM_PATH="$HOME/.gem/ruby/2.0.0"
The path is stolen from the original output of gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14
- RUBY VERSION: 2.0.0
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- RUBY EXECUTABLE: /System/Library/.../2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-14
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/mylogin/.gem/ruby/2.0.0 # <---- This line, right here. -----
- /System/Library/.../usr/lib/ruby/gems/2.0.0
...
No sudoing is required, and you can use the already-installed Ruby, courtesy of Apple.
sudo gem update --system
sudo gem install (gemfile)
There are two routes: Use either rbenv or RVM. There are recipes for both below. Before you do, you probably want to turn off the installation of local documents for gems.
echo "gem: --no-ri --no-rdoc" >> ~/.gemrc
Then:
install rbenv
install ruby-build
run:
rbenv install 2.1.2 (or whatever version you prefer)
rbenv global 2.1.2
gem update --system
This installs an up-to-date version of the gem system in your local directories. That means you don't interfere with the system configuration. If you're asking this question, you shouldn't be messing with system security, and you'll spend longer understanding what issues you may run into, than just having an easy way to avoid the problem you started with. Learn InfoSec later, when you know more about the operating system and programming.
For an alternative use 'RVM' instead: To install rvm run:
rvm install 2.1.2
rvm use 2.1.2
gem update --system
This has the same result, you end up with a local Ruby and Gem system that doesn't interfere with the system versions. There is no need for Homebrew, or over-riding system libs, etc.
I found this how-to for sudoless gem:
brew install rbenv ruby-build
sudo gem update --system
add exports to .bashrc:
export RBENV_ROOT="$(brew --prefix rbenv)"
export GEM_HOME="$(brew --prefix)/opt/gems"
export GEM_PATH="$(brew --prefix)/opt/gems"
And finally add this to your ~/.gemrc:
gem: -n/usr/local/bin
gem update --system
sudo chown -R $USER /Library/Ruby/Gems/
I needed to do a rbenv rehash so it would point to my local Gem library.
It looks like you've got your gem manager pointing to the System Library, so, instead of messing with permissions, do the equivalent of "rehash" for your manager to get things pointing locally.
I had formatted my Mac and many suggested solutions did not work for me.
What worked for me are these commands in the correct order:
Install Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install Ruby:
brew install ruby
Install Compass:
sudo gem install compass
Older and wiser
Don't do what I say here, just know to be wary any time you use sudo. You probably want to use something like rbenv to isolate whatever work you're doing.
a way
learn about chown
I don't know if you like the command line, but this will make working on any project with any tool that installs packages to your system a breeze.
chown as far as I can tell, stands for change ownership.
The reason I came looking for this answer is because gem install threw this error at me today:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /var/lib/gems/1.9.1 directory.
This is a perfect opportunity to use chown. You see Ruby has given us the directory it needs access to, and it seems like it's a directory it will use pretty often.
In this case, there are only three things one needs to know to solve the problem, but chown is much more powerful, and grants you a lot more flexibility than I will demonstrate now. Please refer to the source at the bottom for more information.
The Two Things
Username
Directory
If you're in a shell finding the username is easy. Just look at the prompt. Mine looks like:
breadly#breadly-desktop:~\Desktop
The current user is just the name before the #. We know the directory from the error messages, but you have two choices. You can either limit your permission to the current version by using ../gems/1.9.1, or give yourself write permission for gems of all version by using ../gems.
The command to actually change ownership would look like this.
chown -R $(whoami) /absolute/path/to/directory
The -R is known as a flag and the -R flag typically tells a command to do something recursively, or in other words perform the command on every thing that is contained in the directory, and all the things contained in the directories contained within, and so on till there isn't anything else.
Work for me:
sudo gem uninstall cocoapods
sudo gem install cocoapods
Install rbenv by brew install rbenv;
Then put eval "$(rbenv init -)" at the end of ~/.bash_profile (or ~/.zshrc
of MacOS);
Open a new terminal and run gem install *** will work!
Check to see if your Ruby version is right. If not, change it.
This works for me:
$ rbenv global 1.9.3-p547
$ gem update --system
A 2021 solution (using rvm):
If you type which ruby in terminal, and it shows /usr/bin/ruby, you can try this solution.
install rvm
curl -L https://get.rvm.io | bash -s stable
install ruby using rvm
rvm install "ruby-3.0.0"
use your installed version of ruby
rvm use ruby-3.0.0
type which ruby again, which will show /Users/mac_user_name/.rvm/rubies/ruby-3.0.0/bin/ruby.
It's a new path to use ruby.
Tested on MacOS Mojave WITH SUCCESS:
Uninstall all your old ruby versions (let's say you have 2.00 and 2.3.0):
$ rvm uninstall 2.0.0
$ rvm uninstall 2.3.0
Install brand new ruby version:
$ brew install ruby
Set a default alias to your version:
$ rvm alias create default ruby
Reboot your system because this is the safest way your computer loads the new ruby version, recently installed.
AFTER you done above procedure, you can successfully run any gem command.
As pointed out by bobbdelsol, rehash worked for me :
==> which ruby
/usr/bin/ruby
==> rbenv install 1.9.3-p551
Downloading ruby-1.9.3-p551.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p551.tar.bz2
Installing ruby-1.9.3-p551...
Installed ruby-1.9.3-p551 to /Users/username/.rbenv/versions/1.9.3-p551
==> which ruby
/Users/username/.rbenv/shims/ruby
==> which gem
/Users/username/.rbenv/shims/gem
==> gem install compass
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
==> ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
==> rbenv global 1.9.3-p551
==> ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
==> rbenv global 1.9.3-p551
==> rbenv rehash
==> ruby -v
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-darwin15.4.0]
==> gem install compass
Fetching: sass-3.4.22.gem (100%)
Fetching: multi_json-1.11.3.gem (100%)
Fetching: compass-core-1.0.3.gem (100%)
Fetching: compass-import-once-1.0.5.gem (100%)
Fetching: chunky_png-1.3.5.gem (100%)
Fetching: rb-fsevent-0.9.7.gem (100%)
Fetching: ffi-1.9.10.gem (100%)
Building native extensions. This could take a while...
Fetching: rb-inotify-0.9.7.gem (100%)
Fetching: compass-1.0.3.gem (100%)
Compass is charityware. If you love it, please donate on our behalf at http://umdf.org/compass Thanks!
Successfully installed sass-3.4.22
Successfully installed multi_json-1.11.3
Successfully installed compass-core-1.0.3
Successfully installed compass-import-once-1.0.5
Successfully installed chunky_png-1.3.5
Successfully installed rb-fsevent-0.9.7
Successfully installed ffi-1.9.10
Successfully installed rb-inotify-0.9.7
Successfully installed compass-1.0.3
9 gems installed
Installing ri documentation for sass-3.4.22...
Installing ri documentation for multi_json-1.11.3...
Installing ri documentation for compass-core-1.0.3...
Installing ri documentation for compass-import-once-1.0.5...
Installing ri documentation for chunky_png-1.3.5...
Installing ri documentation for rb-fsevent-0.9.7...
Installing ri documentation for ffi-1.9.10...
Installing ri documentation for rb-inotify-0.9.7...
Installing ri documentation for compass-1.0.3...
Installing RDoc documentation for sass-3.4.22...
Installing RDoc documentation for multi_json-1.11.3...
Installing RDoc documentation for compass-core-1.0.3...
Installing RDoc documentation for compass-import-once-1.0.5...
Installing RDoc documentation for chunky_png-1.3.5...
Installing RDoc documentation for rb-fsevent-0.9.7...
Installing RDoc documentation for ffi-1.9.10...
Installing RDoc documentation for rb-inotify-0.9.7...
Installing RDoc documentation for compass-1.0.3...
You can change GEM_HOME. You have also under your home directory a gem folder to check it use
$ gem env
result is as follows. Unrelated parts are omitted.
...
- GEM PATHS:
- /Users/xxx/.gem/ruby/2.6.0
- /Library/Ruby/Gems/2.6.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0
...
You can use your /Users/xxx/.gem/ruby/2.6.0 folder.
vim ~/.bash_profile
add the following line
export GEM_HOME=~/.gem/ruby/2.6.0/
After that you can use
source ~/.bash_profile
The issue for me was that I switched from zshell to bash earlier and was not logged in:
/bin/bash --login
Although I had rvm installed, it was not able to switch to my newly rvm-installed ruby version and was still trying to use the default Mac-installed ruby binary. Hence my confusion (user error!!!) and the continued permissions issues...
Steps to resolve issue:
Step 1: check and install cocoapods with home brew
brew install cocoapods
Step 2: This is most important, to resolve all the issues, installing
rvm package with stable ruby version, without this you will be
accessing ruby version inside System folder where you don't have
permission.
\curl -sSL https://get.rvm.io | bash -s stable --ruby
Step 3: Add rvm command path to .zshrc file to access it globally
export PATH="$PATH:$HOME/.rvm/scripts/rvm"
Step 4: check if rvm is running properly inside command line globally
rvm --version
Step 5: Now you can install cocoapods package inside user bin as this will
access ruby file from rvm folder, without any permission needed.
sudo gem install -n /usr/local/bin cocoapods
Step 6: Now you can check pod also by using below command
pod install
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0
[2022 Solution]
The detailed reason for the issues has been added here
Summary of the issue -> The issue was related to ruby access, M1 MAC comes with its own ruby. We don't have permission to use that for our purpose. Instead, we install a separate instance of ruby and use it for our purpose.
The below steps helped me resolve the problem, hope this might help some
We don't need to install ruby with rvn or chruby.
My solution uses homebrew to install ruby.
Open the terminal
Install ruby using homebrew
[for fresh install] brew install ruby
[for reinstalling] brew reinstall ruby
Check the path of ruby using the below command
which ruby
It should be installed in the below path
/usr/bin/ruby
To change the ruby path to the user path
To check which shell is used by your system
echo $0
-zsh
For zshrc
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >>~/.zshrc
For bash
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >>~/~/.bashrc
Quit and relaunch the terminal
After changing the path with step 5
Check for the path of the ruby again (execute step 3 - please make sure the path displays as given below)
/usr/local/opt/ruby/bin/ruby
[if you don't quit and launch the terminal, step 4 path will be shown]
This step may not be applicable to everyone can skip step 10 & 11, if you have the correct Cocoapods version installed
Check the version of the pod installed
pod --version
Uninstall the specific version of Cocoapods using the below command
In case the version installed is 1.11.0
gem uninstall cocoapods -v 1.11.0
Install the Cocoapods of the specific version
gem install cocoapods -v 1.11.0
Change the path to the Project directory cd {path of the project directory}
Install the bundler in the project directory
bundle install
Execute pod install
pod install
cd /Library/Ruby/Gems/2.0.0
open .
right click get info
click lock
place password
make everything read and write.
Installing gem or updating RubyGems fails with permissions error Then Type This Command
sudo gem install cocoapods
You can use: gem install cocoapods --pre --user
give the user $whoami to create somethin in those folder
sudo chown -R user /Library/Ruby/Gems/2.0.0