由于某种原因,一些开发人员使用了宝石而其他开发人员不使用。
有时候我会遇到这样的代码:
if File.exist?('USE_MY_GEM')
gem 'my_gem'
end
用USE_MY_GEM
写的和.gitignore
。但我相信这不是很好的做法。
如何为特定机器关闭/打开宝石?
答案 0 :(得分:0)
我会选择Bundler groups feature。这样Gemfile
可能包含组,包含一些开发人员使用的多余gem。
来自文档:
限制要添加到加载路径的gem组。只有这些组中的宝石才需要具备:
require 'rubygems' require 'bundler' Bundler.setup(:default, :ci) require 'nokogiri'
答案 1 :(得分:0)
嗯,解决方案很明显。
我们可以通过管理群组的方式管理宝石。
只需将gem包装在一个组中,然后添加Unhandled Error
Traceback (most recent call last):
File "/opt/zenith/env/local/lib/python2.7/site-packages/twisted/python/log.py", line 73, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/opt/zenith/env/local/lib/python2.7/site-packages/twisted/python/context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/opt/zenith/env/local/lib/python2.7/site-packages/twisted/python/context.py", line 81, in callWithContext
return func(*args,**kw)
File "/opt/zenith/env/local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
why = selectable.doRead()
--- <exception caught here> ---
File "/opt/zenith/env/local/lib/python2.7/site-packages/twisted/internet/udp.py", line 248, in doRead
self.protocol.datagramReceived(data, addr)
File "/opt/zenith/operations/network.py", line 311, in datagramReceived
self.reactFunction(datagram, (host, port))
File "/opt/zenith/operations/schema_sqlite.py", line 309, in writeDatapoint
logger.debug("Data written: {0}".format(dataz))
File "/opt/zenith/operations/model.py", line 1770, in __repr__
repr_info = "Set: {0}, User: {1}, Reps: {2}".format(self.setNumber, self.user, self.repCount)
File "/opt/zenith/env/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 239, in __get__
return self.impl.get(instance_state(instance), dict_)
File "/opt/zenith/env/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 589, in get
value = callable_(state, passive)
File "/opt/zenith/env/local/lib/python2.7/site-packages/sqlalchemy/orm/state.py", line 424, in __call__
self.manager.deferred_scalar_loader(self, toload)
File "/opt/zenith/env/local/lib/python2.7/site-packages/sqlalchemy/orm/loading.py", line 563, in load_scalar_attributes
(state_str(state)))
sqlalchemy.orm.exc.DetachedInstanceError: Instance <Set at 0x1c96b90> is not bound to a Session; attribute refresh operation cannot proceed
选项:
--without
Gemfile
在控制台中:
group :my_gem do
gem 'my_gem'
end
确保$ bundle install --without my_gem
包含:
.gitignore