ledger-mode
ledger-mode copied to clipboard
Error when including a file with a relative path (ledger 3.2.1)
Since upgrading to ledger v. 3.2.1, I now get the following message when running several emacs ledger commands (filename redacted):
While parsing file "", line 1:
Error: File to include was not found: "<included_file>.ledger"
When calling ledger from the command-line, I get the normal behavior (file is included, and there is no error). I am also able to run ledger-report with no problems.
I tested with ledger 3.1.3, and the file was included by ledger-mode as normal.
when running several emacs ledger commands
Could you perhaps name one of those commands, as a helpful clue? 🙂
Oops, I can see how that would be helpful. It happens with both ledger-reconcile and ledger-display-balance-at-point
Thanks. Other questions:
- When you run ledger manually, you presumably run it in the directory of the file that contains the include directive?
- Is the included file in the same directory, and is its path a relative one?
Basically I'm trying to figure out how one might reproduce this.
I have a setup like this:
~/.ledger_data:
closing.ledger
main.ledger
The first line of main.ledger is include closing.ledger, and my ledgerrc is just --file ~/.ledger_data/main.ledger. I can run ledger from any directory, and the relative file is included as expected. It was also included when I ran ledger-reconcile in emacs, until I upgraded ledger to 3.2.1.
(As a side note, I don't want to use an absolute path here, because I sync these files between my Mac laptop and Linux server, where my home directories have different names)
You might consider setting ledger-master-file, e.g. in a .dir-locals.el file. For example, in my ledger files directory I have a .dir-locals.el like this:
((ledger-mode . ((ledger-master-file . "master.ledger"))))
I mean, it probably shouldn't be necessary for your case above to work, but just wanted to mention that var.
I added the file as suggested, and I'm still getting the same error.
Are you using nixpkgs? There's a regression in nixpkgs that leads to an error message like this because of an upgrade to the boost package, see NixOS/nixpkgs#151469.
I'm not using nixpkgs; ledger is managed by homebrew on MacOS, and ledger-mode is via el-get, whose recipe says it's getting it from github.
The version of boost in homebrew is similarly new (1.78), so I think it's likely the same issue. See also https://github.com/ledger/ledger/issues/2075
Does that mean this needs to be fixed in ledger or in boost? Homebrew "helpfully" got rid of the switch command, so it's now all but impossible to downgrade a package.
According to the linked issue, this was fixed in Ledger in https://github.com/ledger/ledger/pull/2092, but the fix isn't in any released version of Ledger. So probably what's needed is a fresh Ledger release, which appears overdue.