Do I have to manually uninstall all dependent gems?

前端 未结 9 2156
名媛妹妹
名媛妹妹 2020-12-08 06:50

I tried to uninstall datamapper using the command gem uninstall dm-core.

But it seems that a whole bunch of dependent gems also need to be uninstalled.

相关标签:
9条回答
  • 2020-12-08 07:00

    Just list all the gems you want to uninstall e.g. gem uninstall dm-migrations dm-cli dm-observer. And try to manage your gems with Bundler whenever possible.

    0 讨论(0)
  • 2020-12-08 07:01

    gem cleanup should do the trick. See here for details.

    0 讨论(0)
  • 2020-12-08 07:10
    for gem in `gem list --no-version`; do
      gem uninstall -aIx $gem
    done
    

    Works the best for me, not sure why but

    gem list | cut -d" " -f1 | xargs gem uninstall -aIx
    

    doesn't work on my system as it still complains...

    ERROR:  While executing gem ... (Gem::InstallError)
        cannot uninstall, check `gem list -d some-gem-here`
    
    0 讨论(0)
  • 2020-12-08 07:11

    If you would like to use some wild cards to remove some gems (e.g. to remove some gems from a specific vendor) then you can pipe the output from gem list to grep as shown below

    gem list --no-version | grep "opener-" | cut -d " " -f1  | xargs gem uninstall -aIx
    

    The above command removes all the gems whose name begins with "opener-"

    0 讨论(0)
  • 2020-12-08 07:15

    gem list | cut -d" " -f1 | xargs gem uninstall -aIx deletes all installed ruby gems!

    0 讨论(0)
  • 2020-12-08 07:18

    As far as I know you're correct, there is not an easy way built-in to the gem command to do this.

    However, you can check out gem-prune which can help clean up your gem repository after you've removed dm-core.

    http://github.com/ddollar/gem-prune/tree/master

    0 讨论(0)
提交回复
热议问题