Gem install issue

I’ve been moving through the curriculum without a problem until just recently. I’m on the new version’s rspec 1 exercises and keep coming across this error when attempting to install my gem files:

~/downloads$ cd appacademy-online-rspec-1-7db389dec276
~/downloads/appacademy-online-rspec-1-7db389dec276$ gem install bundler
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ rb_sysopen - /Users/[my user name]/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.0/CHANGELOG.md

Anyone have any idea what the permission denied could be referring to?

1 Like

Hi there!

Could you try running the following commands in your terminal:

  • which ruby
  • ruby -v

and let me know what the output of each is?

@albronca Thanks so much!

which ruby:
/.rbenv/shims/ruby
ruby -v:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]

Hmmmm, all that looks good to me. Any chance you recently updated your OS? That could potentially modify permissions. :man_shrugging: It might be worthwhile to just try re-installing rbenv and Ruby. If you want, I could walk you through that.

@albronca That would be amazing. Dm’d you :slightly_smiling_face:

@albronca I’m dealing with the same issue when installing the bundler

Here’s what I get after I input gem install bundler

ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

I get these outputs for the commands you listed above

/usr/bin/ruby
ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]

@keonch DMing you about this - hopefully your situation is the same as mine!

1 Like

@keonch @lsiler23 let me know if you get it working!

Hello @albronca
I uninstalled rbenv and reinstalled it with ruby 2.3.1. Then I redid everything with ruby 2.3.0, yet I couldn’t get it to work. I still get the same error when I try to gem install bundler

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

and which ruby still gives you /usr/bin/ruby?

I get
/Users//.rbenv/shims/ruby

Before you tried running gem install bundler, had you opened a new Terminal tab to make sure all the changes you’d made were reloaded?

Yes, I have. I followed these instructions step by step.

brew ls
Assuming it is listed there, let’s then run

brew uninstall rbenv
Next navigate to your root directory (aka ~) via your terminal and run

rm -rf .rbenv
That should be good enough for us to reinstall, so run

brew install rbenv
Open a fresh terminal tab and make sure that running which rbenv returns /usr/local/bin/rbenv. If that works, try reinstalling the version of ruby you had before (this part takes a little while) with

rbenv install 2.3.1
Again, open a fresh terminal tab and make sure that running which ruby returns something like /Users//.rbenv/shims/ruby. If that’s good, try gem installing bundler again.

What do you get when you run which gem?

I get
/Users/myname/.rbenv/shims/gem

Can you try rbenv global 2.3.1, then open a new tab and try installing bundler again?

1 Like
Fetching: bundler-1.16.1.gem (100%)
Successfully installed bundler-1.16.1
1 gem installed

Awesome, it’s working! I got the rspec working as well. Thank you!

1 Like