2

Like many people I created a dotfiles repo and am trying extract bits that are not private into their respective dotfiles. I generally have a .whatever.local file loaded if it's present which might contain information I don't want checked into a repository. Rubygems use ~/.gemrc file, but I can't see a way to extract private information out of it into separate file. Does anyone know how this might be done?

In particular I'd like to have the list of sources external to the .gemrc file.

1 Answer 1

4

I do not see an equivalent to .local as per v2.4.6 (a recent, but not last version).

The source code of RubyGems states something relevant for what you want to achieve, though. For example, in 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)

So you could use the GEMRC environment variable to load extra, private files as well.

3
  • 1
    This works. Though, one annoying thing is that you have to repeat all the listing of all :sources: in the file pointed to by GEMRC the values in this file overwrite the current settings (though I can understand why they've done it that way).
    – rainkinz
    Jan 29, 2016 at 22:36
  • Yes, it works by file... All or nothing for each file. Perhaps there is little demand so far for finer granularity? Jan 30, 2016 at 6:52
  • 1
    I literally took a look at coding something up, but given that this question doesn't seem to have come up before decided it was probably a very rare requirement.
    – rainkinz
    Jan 30, 2016 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.