简体   繁体   English

我如何不捆绑package:path gems?

[英]How do I not bundle package :path gems?

In our project, we ran bundle package --all one time, which according to documentation, remembers the "--all" option in subsequent calls. 在我们的项目中,我们一次运行了捆绑包--all,根据文档,它会记住后续调用中的“ --all”选项。 If I want to test a gem on my project by hardcoding it's path into the Gemfile such as: gem 'blocks', :path => "/Users/hunterae/Projects/blocks", anytime I run bundle install, all of the source code for this gem will be copied into my /vendor/cache directory. 如果我想通过将项目的路径硬编码到Gemfile中来测试项目中的gem,例如:gem'blocks',:path =>“ / Users / hunterae / Projects / blocks”,则无论何时运行捆绑安装,所有源代码该gem的代码将复制到我的/ vendor / cache目录中。 This means that if I make a change to the gem I am testing, I have to shut down my rails server and run bundle install again, whereas before "bundle package --all" was run, I used to be able to just stop and start my rails server. 这意味着,如果我对要测试的gem进行更改,则必须关闭我的rails服务器并再次运行bundle install,而在运行“ bundle package --all”之前,我曾经能够停止并启动我的Rails服务器。

My question is how do I get "bundle package" to once again only package gems and not try and cache :path gems? 我的问题是如何使“捆绑包”再次仅打包宝石而不尝试缓存:path宝石? Where is the "--all" option remembered in bundler? 捆绑程序中还记得“ --all”选项吗?

Look in .bundle/config in your project directory for a line that says BUNDLE_CACHE_ALL: true . 在您的项目目录中的.bundle/config中查找一行显示BUNDLE_CACHE_ALL: true

Delete that line to make it revert to packaging only standard gems. 删除该行,使其恢复为仅包装标准宝石。

In general, remembered options are stored in .bundle/config . 通常,记住的选项存储在.bundle/config

+1 to the answer form Tim Moore. +1到Tim Moore的答案中。 Following is an addition to it. 以下是对它的补充。

You should avoid using :path in your Gemfile if possible and if working with a gem available on github. 如果可能并且使用github上可用的gem时,应避免在Gemfile中使用:path。 Since Bundler 1.9 you can use sth. 从Bundler 1.9开始,您可以使用sth。 like 喜欢

bundle config local.name_of_gem /path/to/checked_out/repo

This will add an entry in ~/.bundle/config like 这将在〜/ .bundle / config中添加一个条目,例如

less ~/.bundle/config
---
BUNDLE_LOCAL__NAME_OF_GEM:     
"/path/to/checked_out/repo/name_of_gem"

You can remove the config with the same command and including --delete like 您可以使用相同的命令删除配置,包括--delete

bundle --delete config local.name_of_gem /path/to/checked_out/repo

This will avoid many problems and is easy to maintain. 这样可以避免许多问题,并且易于维护。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM