las*_*igh 99 uninstall bundler ruby-on-rails-3
我通过Gemfile使用bundler安装了所有宝石.我(错误地)认为如果我从我的Gemfile中删除了一个gem并运行'bundle install',那么将删除已删除的gem.我查看了捆绑器帮助文件,据我所知,它没有办法卸载宝石.
我只是使用gem uninstall x来做所有事情吗?这会让捆绑者感到困惑吗?
Dan*_*iel 135
Bundler是从您的应用程序的根目录启动的,因此它确保所有需要的宝石都可以使您的应用程序正常工作.如果由于某种原因您不再需要宝石,您将不得不运行
gem uninstall gem_name
Run Code Online (Sandbox Code Playgroud)
如上所述.所以每次运行bundler时都会重新检查依赖项
编辑 - 2014年12月24日
我看到人们不断回答这个问题我决定添加一些东西.我给出的答案就是你保持全球宝石的情况.考虑使用诸如rbenv或rvm之类的gem管理器来保存作用于特定项目的宝石集.
这意味着在全局级别不会安装任何gem,因此当您从项目的Gemfile中删除一个Gemfile并重新运行bundle时,它显然不会加载到您的项目中.然后,您可以运行bundle clean(使用项目目录),它将从系统中删除所有那些曾经从您的Gemfile(在同一目录中)安装的gem,但在此给定时间不再列在那里....长话短说 - 它删除了未使用的宝石.
pha*_*ann 96
这将卸载由bundler安装的gem:
bundle exec gem uninstall GEM_NAME
Run Code Online (Sandbox Code Playgroud)
请注意,此抛出
错误:执行gem时...(NoMethodError)未定义方法`delete'for#<Bundler :: SpecSet:0x00000101142268>
但宝石实际上已被删除.下次运行bundle install
gem时将重新安装.
Evg*_*ova 21
使用较新版本的bundler,您可以使用clean任务:
$ 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)
...
Run Code Online (Sandbox Code Playgroud)
编辑:
如果您使用全局gemset(即 - 所有项目都将其宝石保存在同一位置),则不建议这样做.但是,几乎没有办法让每个项目的宝石分开:
rvm
gemsets(http://rvm.io/gemsets/basics)bundle install
使用以下任何选项:--deployment
或--path=<path>
(http://bundler.io/v1.3/man/bundle-install.1.html)