Help! "ERROR: while executing gem..."

Hi,

When i run: ~/.dotfiles/bin/install_dotfiles , I get this error:

install_requirements: Ruby v2.3.1 already installed.
install_requirements: Ruby v2.3.1 set as default version.
install_requirements: Installing bundler and gems…
install_requirements: Press enter to continue.

ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
/Users/danielnam/.dotfiles/bin/install_requirements: line 101: bundle: command not found
install_requirements: Gems installed

Can someone please help me with this? It looks like ruby 2.3.1 is good to go, but when i type “ruby -v” i get ruby 2.0.0. I think this is all connected to the error which I try to “bundle install”, which produces this error:

-bash: bundle: command not found

In addition, when I run ~/.dotfiles/bin/install_dotfiles, it says:

Continue? (y/n)
y
/Users/danielnam/.dotfiles/bin/.install_dotfiles.rb:56:in `write’: Permission denied - /Users/danielnam/.bash_profile (Errno::EACCES)

I wonder if this is all part of the same problem.

Please help! Thank you!

Dan

Hi Dan,

Not sure if you’ve already figured this out, but regarding the gem installation error, this is what helped me:

  1. In Terminal, enter open ~/.bash_profile
  2. Add eval "$(rbenv init -)" to the end of the file and save
  3. Back to Terminal, enter rbenv global 2.3.1
  4. Exit and reopen Terminal
  5. Enter ruby -v or gem env home to check that 2.3.1 is the Ruby version being used

Afterward, the gem install bundler command should work, which allows you to use bundle install and bundle exec rspec in your root project folder for the exercises. You may also need to run gem install rubocop if you get RuboCop errors in Atom.

Thanks Vickie! With your suggestion, I tried “sudo gem install rubocop” and it looks like it fixed the issue with Atom.

I think I need to do your first five steps to be fully updated though too. Step 1 brings up a terminal window for me, but I can’t seem to be able to edit it. My window says:

Last login: Mon Aug 14 19:21:29 on ttys001
daniels-macbook:~ danielnam$ /Users/danielnam/.bash_profile ; exit;
logout
Saving session…
…copying shared history…
…saving history…truncating history files…
…completed.

[Process completed]

Did I bring up the right thing?

That command opens ~/.bash_profile in TextEdit for me. You can try this instead:

  1. nano ~/.bash_profile to open the file with command line editor
  2. Add eval "$(rbenv init -)" to the end of the file
  3. ctrl + O and enter to save
  4. ctrl + X to exit
  5. source ~/.bash_profile to activate changes in current Terminal session

It’s also recommended that you not install gems to your system Ruby, so you may want to uninstall RuboCop and install it again once you’ve switched over to 2.3.1 in rbenv.