简体   繁体   English

捆绑器,rubygems和动态使用宝石

[英]bundler, rubygems and dynamic use of gems

I'm developing a gem with uses bundler for its dependency management. 我正在开发一个使用bundler进行依赖管理的gem。

Now I want to use some gems but only when they are already installed in the system (shown by gem list), so I cannot add them to the Gemfile. 现在我想使用一些宝石,但只有当它们已经安装在系统中时(由gem list显示),所以我无法将它们添加到Gemfile中。 Doing a simple 做一个简单的

require("rmagick") 

does not work because bundler seems to hide all gems not listed in the Gemfile. 不起作用,因为bundler似乎隐藏了Gemfile中未列出的所有宝石。 A simple test.rb without bundler and just containing 一个简单的test.rb没有捆绑器,只是包含

require "rubygems"
require "rmagick

works without any problems. 工作没有任何问题。

Anybody knows how to require a gem which is not listed in the Gemfile? 有谁知道如何要求Gemfile中没有列出的gem?

As far as I know you have to include it in your Gemfile , or include it prior to using bundler . 据我所知,你必须将它包含在你的Gemfile ,或者在使用bundler之前包含它。 If you include it after you get an error. 如果在收到错误后包含它。 There may be a way to turn that off but I can't find it. 可能有办法将其关闭,但我找不到它。

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

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