Having trouble installing PRY

When I type into the terminal “gem install pry” it gives me back the message:

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

I understand that it’s telling me that I don’t have permission but I don’t get why.
can anyone help me understand what’s going on? I’ve tried looking it up online and it’s not helping me figure it out.
Thanks in advance.

Figured it out.
I ran “sudo gem install pry” and it worked.
Thanks anyways

Actually still having issues… I tried to install the pry -doc so I could get documentaion on different methods and it somehow messed up the pry I just installed. Now when I pry type in the pry command, I receive this error

I’m lost on where to go from here.

Hi Carey,

Does this help with your issue?

I typed in “atom ~/.bashrc” in the terminal, and the file that opened up in Atom contained the line “export PATH=”$HOME/.rbenv/bin:$PATH"

When I type in the pry command I still get the same error I posted about earlier.

I would uninstall both the pry gem and the pry-doc gem. Then make sure that you went through everything described here. If you’re still having issues, make sure that your .bashrc contains the line eval "$(rbenv init -)". If it doesn’t, add it and restart your terminal.

Thanks for the help. Everything seems to be working fine with pry. Only other question i have now is how to I use the “load” command in pry to load up Ruby code from a saved file? I’m trying to follow along in the debugging section and it mentions using the “load” command. I can’t seem to get it to work.

What have you tried so far? Generally, the way it works like this: Say you want to load up a file called script.rb in pry. You first cd into the directory where script.rb is. Then you open pry. Then you type load 'script.rb'.

Thank you for your advice, I was finally able to figure it out! The problem was that I wasn’t opening pry from the directory that my specific file was in. Thankfully an easy fix :sunglasses:

1 Like