two .ledgerrc in $HOME

Skip to first unread message

lipp f

Oct 22, 2023, 2:00:23 PM10/22/23
to Ledger
$ find ~ -name \*.ledgerrc

The default one supposed to be for myself and t14 for my business. Expecting to be completely separated. Each file has one or more --file entry, no overlap.

$ ledger -i ~/t14.ledgerrc stats 
$ ledger -i ~/.ledgerrc stats

show actually only the default data, never the t14. 

I was expecting that whenever an init file is specified, the default one wouldn't be used. Is this a bug?

Enrico Lamperti

Oct 24, 2023, 7:03:37 PM10/24/23
It's the expected behavior. Dotfiles in your home folder usually have global settings, so having more than one is a bad practice. 

You may have your common rules in it, and then in the directory where you have each ledger file (e.g. `~/work` and `~/personal`) you can have another `.ledgerrc` with specific settings for each project if you need.

Also, instead of sourcing many files with `--file` you may use includes in a main ledger file, e.g.:

    include accounts.ledger
    include 2022.ledger
    include 2023.ledger
    include loans/friends.ledger

Then you just have to specify this file with `--file` and all the others will be included as you want.

This could even simplify your two `.ledgerrc` files down to a single one, because if you specify e.g. "--file main.ledger", I think it should work in both directories.


You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

lipp f

Oct 25, 2023, 11:24:41 AM10/25/23
to Ledger
If I understand you correctly ~/.ledgerrc should never contain --file or --include options, but only general options, and each project should be contained in its own folder. I still have couple of questions:
- when I have an  ~/.ledgerrc and another  .ledgerrc in project folder, is the second one loaded, assuming that working directory is  project folder when I invoke ledger? Which order?
- the documentation for include says "Include the stated file as if it were part of the current file. The file name can contain a wildcard (‘*’) to refer to multiple files (e.g. ‘bank/*.ledger’)" which is really useful. Is there any way to specify the working directory in .ledger or to use shell variables for include / file options?


lipp f

Oct 25, 2023, 5:27:24 PM10/25/23
to Ledger
I did some more testing:
- once you have the ~/.ledgerrc, a working directory  .ledgerrc gets ignored
- -i and --init-file have inconsistent behaviour (according to the documentation, it should be the same, but it is not)

$ cat ~/.ledgerrc
--date-format %Y-%m-%d
--sort date
$ ledger  stats
Error: No journal file was specified (please use -f)
$ ledger -i .ledgerrc stats
Error: No journal file was specified (please use -f)
$ ledger --init-file .ledgerrc stats
Time period: 2000-01-01 to 2023-10-24 (8697 days)

  Files these postings came from:
  < correct list of files here >

  Unique payees:            2273
  Unique accounts:            96

  Number of postings:      10191 (1.2 per day)
  Uncleared postings:        724

  Days since last post:        1
  Posts in last 7 days:       12
  Posts in last 30 days:      65
  Posts seen this month:      43

Reply all
Reply to author
0 new messages