【问题标题】:Is there a .gemrc.local or equivalent?是否有 .gemrc.local 或同等文件?
【发布时间】:2016-01-28 09:35:10
【问题描述】:

像许多人一样,我创建了一个 dotfiles 存储库,并尝试将非私有的位提取到各自的 dotfile 中。我通常会加载一个.whatever.local 文件(如果存在),其中可能包含我不想签入存储库的信息。 Rubygems 使用~/.gemrc 文件,但我看不到将私人信息从中提取到单独文件中的方法。有谁知道这是怎么做到的?

我特别希望将sources 列表放在 .gemrc 文件之外。

【问题讨论】:

    标签: ruby rubygems


    【解决方案1】:

    根据 v2.4.6(最新版本,但不是最新版本),我没有看到与 .local 等效的版本。

    RubyGems 的源代码说明了一些与您想要实现的目标相关的内容。例如在src/ruby-2.3.0/lib/rubygems/config_file.rb:

    ##
    # Gem::ConfigFile RubyGems options and gem command options from gemrc.
    #
    # gemrc is a YAML file that uses strings to match gem command arguments and
    # symbols to match RubyGems options.
    #
    # Gem command arguments use a String key that matches the command name and
    # +:sources+:: Sets Gem::sources
    # +:verbose+:: See #verbose
    #
    # gemrc files may exist in various locations and are read and merged in
    # the following order:
    #
    # - system wide (/etc/gemrc)
    # - per user (~/.gemrc)
    # - per environment (gemrc files listed in the GEMRC environment variable)
    

    因此您也可以使用GEMRC 环境变量来加载额外的私有文件。

    【讨论】:

    • 这行得通。不过,一件烦人的事情是,您必须在 GEMRC 指向的文件中重复所有 :sources: 的所有列表,该文件中的值会覆盖当前设置(尽管我可以理解他们为什么这样做)。
    • 是的,它按文件工作...每个文件全有或全无。也许到目前为止对更细粒度的需求很少?
    • 我从字面上看了一下编码的东西,但考虑到这个问题似乎没有出现之前,我决定这可能是一个非常罕见的要求。
    猜你喜欢
    • 2019-08-14
    • 2010-10-13
    • 2013-10-31
    • 2013-09-23
    • 2011-11-14
    • 2015-11-03
    • 2022-12-14
    • 2020-11-30
    相关资源
    最近更新 更多