gpt4 book ai didi

ruby-on-rails - Gemfile 和 gemspec 中必须有什么样的依赖关系?

转载 作者:行者123 更新时间:2023-12-05 03:13:45 27 4
gpt4 key购买 nike

无法弄清楚 rails gem 必须在哪里指定其依赖项?在 gemspec 中的 Gemfile 中?生成的 Gemfile 具有以下描述:

# Declare your gem's dependencies in malibu.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec

# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

不过我还是能看懂。你能帮助我吗?我的感谢

最佳答案

如果您正在开发新的 gem,那么您需要使用 add_dependency.gemspec 中声明所有可用于生产的 gem。

至于 Gemfile 本身,如评论所述,它用于添加仍在开发中(即未发布)的依赖项。例如,如果您想使用 Rails 的最新边缘版本,您必须使用 gitgithub 选项指定该依赖项(例如 gem "rails", github: "rails/rails").这些选项仅在 Gemfile 中可用,在 .gemspec 中不可用。

通常,您希望始终将依赖项放在 .gemspec 中,并且仅在需要时才使用 Gemfile。

关于ruby-on-rails - Gemfile 和 gemspec 中必须有什么样的依赖关系?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28898150/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com