below is what I need to do.
To run the specs, you'll need to install RSpec. First, run gem install bundler in the root directory of your project. Then, run bundle install. To run a single spec file, run a command like this: bundle exec rspec spec/00_hello_spec.rb. To run all of the specs at once, run bundle exec rspec.
So, I typed gem install bundler to terminal, and got You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
and this was in the project file in atom *source "https://rubygems.org" gem "rspec", "~> 3.2.0" *
My question is:
It seems like terminal is giving me the response because I'm not supposed to change anything on ruby, and I need to bundle install inside of atom? Could anyone tell me how to use atom or run anything in atom?
Thank you so much!
You are correct that macOS won't let you change anything with the Ruby version that comes installed with your Mac. However, it's possible to install gems like
bundler using a separate version of Ruby that doesn't interfere with the one provided by Apple.
sudo to install gems, or changing permissions of system files and directories is strongly discouraged, even if you know what you are doing. Can we please stop providing this bad advice?
The solution involves two main steps:
- Install a separate version of Ruby that does not interfere with the one that came with your Mac.
- Update your
PATHsuch that the location of the new Ruby version is first in the
PATH. The list of directories, and the order in which the computer looks them up to find executable programs is called the
PATH. If you type
echo $PATHin Terminal, you will see the list of directories, separated by a colon.
There are several ways to install Ruby on a Mac. The best way that I recommend, and that I wish was more prevalent in the various installation instructions out there, is to use an automated script that will set up a proper Ruby environment for you. This drastically reduces the chances of running into an error due to inadequate instructions that make the user do a bunch of stuff manually and leaving it up to them to figure out all the necessary steps.
The other route you can take is to spend extra time doing everything manually and hoping for the best. First, you will want to install Homebrew, which makes it easy to install other tools and macOS apps.
Then, the 4 most popular ways to install a separate version of Ruby are:
If you don't need more than one version of Ruby at the same time (besides the one that came with macOS)
- Homebrew - once it's installed, install ruby with
brew install ruby, then update your
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile, followed by
If you would like the flexibility of easily switching between many Ruby versions
rbenv - can be installed with Homebrew
To check that you're now using the non-system version of Ruby, you can run the following commands:
It should be something other than
It should be something other than 2.3.7. As of today, 2.6.1 is the latest Ruby version.
Once you have this new version of Ruby installed, you can now install bundler:
gem install bundler
If you don't want to run
sudo then install ruby using homebrew
brew install ruby export GEM_HOME="$HOME/.gem" gem install rails
You may want to add
export GEM_HOME="$HOME/.gem" to your
.zshrc if you're using zsh
I have faced same issue after install macOS Catalina. I had try below command and its working.
sudo gem update
$ rbenv init # Load rbenv automatically by appending # the following to ~/.zshrc: eval "$(rbenv init -)"
Follow instructions, (in my case add to ~/.zshrc) ;)
Also important: Changes only take effect if you reboot your console. Two options
source <modified file>
- close and open again