在我看来,PATH 直接从您的 gemspec 中列出了第一代依赖项,而 GEM 列出了第二代依赖项(即您的依赖项所依赖的内容)和 Gemfile 中的那些。 PATH::remote 是 .,因为它依赖当前目录中的本地 gemspec 来找出 PATH::spec 中的内容,而 GEM::remote 是 rubygems.org,因为它必须去那里才能找到GEM::spec 中的内容。
在 Rails 插件中,您会看到 PATH 部分,但在 Rails 应用程序中看不到。由于该应用没有 gemspec 文件,因此不会在 PATH 中放置任何内容。
至于依赖关系,gembundler.com 声明:
Runtime dependencies in your gemspec are treated like base dependencies,
and development dependencies are added by default to the group, :development
rails plugin new my_plugin 生成的 Gemfile 说了类似的话:
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
这意味着两者的区别
s.add_development_dependency "july" # (1)
和
s.add_dependency "july" # (2)
是 (1) 将仅在开发环境中的 Gemfile.lock(因此在应用程序中)中包含“july”。因此,当您运行bundle install 时,您不仅会在 PATH 下而且还会在 DEPENDENCIES 下看到“july”,而且只会在开发中看到。在生产中,它根本不存在。但是,当您使用 (2) 时,您只会在 PATH 中看到“july”,而不是在 DEPENDENCIES 中,但是当您在生产环境中 bundle install 时(即在包含您作为依赖项的其他 gem 中)时,它会显示),不仅仅是开发。
这些只是我的观察,我无法完全解释为什么会这样,但我欢迎更多的 cmets。