0

From my understanding (And from what I've seen by using this) if a project has a Gemfile, it only has access to gems that are in the Gemfile (Or more specifically, the Gemfile.lock file).

I want to be able to use some gems that are installed on the system, but not particularly in the Gemfile.lock file - How would I go about this?

For my reasoning: We have a developer VM setup that ensures everything is up to date; however without running bundle update within the project, a tool that we use (That relies on a Gem) cannot be updated (Or even used, if it isn't in the Gemfile).

I can keep the gem updated, but cannot force the project to use the version without updating the Gemfile.lock information - So I would prefer to just let the project use all or specific system gems, and just have the Gemfile as a "quick way to get your system up to date with the project".

Another note: The application uses rake tasks to operate (Tool has a gem, the gem looks for a specific rake file for custom configuration).

4

2 回答 2

1

您的系统 gem 安装在哪里?

确保将GEM_PATHenv var 设置为该位置。

用于gem env gempath检查您的设置是否正确。

如果没有,请将其设置为~/.bashrc~/.bash_profile

export GEM_PATH='/path/to/system/gems'
于 2012-10-10T20:39:44.903 回答
0

您只需要需要该库(阅读 gem)。

您可以在使用 gem 功能的特定文件中要求它,或者您可以在config/application.rb(在 Rails 3 中)要求它以使其可用于整个应用程序。

为了安全起见,请确保 gem 可用:

if Gem::Specification::find_by_name('my_gem')
  require 'my_gem'
end
于 2012-10-10T17:51:15.853 回答