3
user@machine:~$ gem list

*** LOCAL GEMS ***

bigdecimal (1.2.8)
did_you_mean (1.0.0)
io-console (0.4.5)
json (1.8.3)
minitest (5.8.4)
net-telnet (0.1.1)
power_assert (0.2.7)
psych (2.0.17)
rake (10.5.0)
rdoc (4.2.1)
sass (3.4.23)
test-unit (3.1.7)
user@machine:~$ sudo gem uninstall rake
ERROR:  While executing gem ... (Gem::InstallError)
    rake is not installed in GEM_HOME, try:
    gem uninstall -i /usr/share/rubygems-integration/all rake
user@machine:~$ sudo gem uninstall -i /usr/share/rubygems-integration/all rake 
Remove executables:
    rake

in addition to the gem? [Yn]  Y
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/share/rubygems-integration/all/bin directory.
user@machine:~$ ls /usr/share/rubygems-integration/all/
specifications
user@machine:~$ 

I can not uninstall this gem in particular, neither use it :( If seems that it doesn't exist.

My ruby verison is 2.3.1.p112

Daniel Gonzalez
  • 63
  • 1
  • 1
  • 4

2 Answers2

7

Ideally you would use RVM or rbenv to create a local sandbox and handle your Ruby install and gems instead of the system default. Then you won't have to use sudo you can just use gem uninstall <gem>. It doesn't let you have access for a reason, so it's harder to accidentally mess up the system Ruby.

If you can just read these install directions to get set up with RVM and then install the gems you used previously in your new environment. It'll save you a lot headaches in the future managing Ruby and gems.

--

If you don't want to do that you could try this answer

Try this answer from this related question.

gem list -d 'name of gem' and note the "Installed at:" location

sudo gem uninstall 'name of gem' -i 'the path noted above'

If it still returns a permissions error. Create a folder /bin, in the path above. Continue uninstalling as in step 2, still using the original path (/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8).

Community
  • 1
  • 1
1

sudo is not a magic wand that casts a spell “do it anyway.”

When you list your gems, you execute plain gem list from the user. It lists gems installed for the user. Afterwards you try sudo gem uninstall rake. Why do you expect superuser’s list of gems being the same as user’s one?

To remove user’s gems, listed with gem list, use gem uninstall rake. Without sudo.

To list superuser’s gems, that you were tried to remove with sudo gem uninstall rake, use sudo gem list. With sudo.

More info on sudo: http://aplawrence.com/Basics/sudo.html

Aleksei Matiushkin
  • 119,336
  • 10
  • 100
  • 160
  • I was uninstalled but for some reason there were some files remaining. I removed manually and everything is fine now. I tried to install rake and uninstall it and now works fine. – Daniel Gonzalez Mar 06 '17 at 09:00