What is the best way to uninstall gems from a rails3 project?

后端 未结 7 794
花落未央
花落未央 2021-01-29 23:25

I installed all of my gems using bundler via the Gemfile. I thought (mistakenly) that if I deleted a gem from my Gemfile and ran \'bundle install\' that the deleted gems would b

7条回答
  •  既然无缘
    2021-01-30 00:08

    With newer versions of bundler you can use the clean task:

    $ bundle help clean
    Usage:
        bundle clean
    
    Options:
        [--dry-run=only print out changes, do not actually clean gems]
        [--force=forces clean even if --path is not set]
        [--no-color=Disable colorization in output]
        -V, [--verbose=Enable verbose output mode]
    
    Cleans up unused gems in your bundler directory
    $ bundle clean --dry-run --force
    Would have removed actionmailer (3.1.12)
    Would have removed actionmailer (3.2.0.rc2)
    Would have removed actionpack (3.1.12)
    Would have removed actionpack (3.2.0.rc2)
    Would have removed activemodel (3.1.12)
    ...
    

    edit:

    This is not recommended if you're using a global gemset (i.e. - all of your projects keep their gems in the same place). There're few ways to keep each project's gems separate, though:

    1. rvm gemsets (http://rvm.io/gemsets/basics)
    2. bundle install with any of the following options: --deployment or --path= (http://bundler.io/v1.3/man/bundle-install.1.html)

提交回复
热议问题