bundle-pristine - 将已安装的 gem 还原到原始状态
bundle pristine
pristine 使用 RubyGems 的本地 gem 缓存将捆绑包中已安装的 gem 还原到原始状态。对于 git gem,将执行强制检出。
为了进一步说明,bundle pristine 会忽略磁盘上的解压缩文件。换句话说,此命令使用本地 .gem 缓存或 gem 的 git 仓库,就像从头开始安装一样。
注意:Bundler gem 无法使用 pristine 还原到其原始状态。此外,无法对 Gemfile 中具有“path”选项的 gem 使用 bundle pristine,因为 bundler 没有可以从中还原的原始副本。
何时使用 bundle pristine 比较实用?
当开发人员调试 gem 时,它会派上用场。bundle pristine 是摆脱对 gem 的实验性更改的好方法,这些更改可能不需要。
为什么使用 bundle pristine 而不是 gem pristine --all?
这两个命令非常相似。为了说明:bundle pristine(不带参数)会清理锁文件中的所有 gem。同时,gem pristine --all 会清理该 Ruby 版本安装的所有 gem。
如果开发人员忘记了他们可能调试过的项目中的哪些 gem,Rubygems gem pristine [GEMNAME] 命令可能不方便。可以避免等待 gem pristine --all,而是运行 bundle pristine。