ledger-mode icon indicating copy to clipboard operation
ledger-mode copied to clipboard

Error when including a file with a relative path (ledger 3.2.1)

Open bgainor opened this issue 3 years ago • 12 comments

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.

bgainor avatar Mar 17 '22 21:03 bgainor

when running several emacs ledger commands

Could you perhaps name one of those commands, as a helpful clue? 🙂

purcell avatar Mar 18 '22 09:03 purcell

Oops, I can see how that would be helpful. It happens with both ledger-reconcile and ledger-display-balance-at-point

bgainor avatar Mar 18 '22 12:03 bgainor

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.

purcell avatar Mar 18 '22 12:03 purcell

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.

bgainor avatar Mar 18 '22 12:03 bgainor

(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)

bgainor avatar Mar 18 '22 12:03 bgainor

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.

purcell avatar Mar 18 '22 13:03 purcell

I added the file as suggested, and I'm still getting the same error.

bgainor avatar Mar 18 '22 14:03 bgainor

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.

bcc32 avatar Mar 18 '22 16:03 bcc32

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.

bgainor avatar Mar 21 '22 15:03 bgainor

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

purcell avatar Mar 21 '22 16:03 purcell

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.

bgainor avatar Mar 22 '22 15:03 bgainor

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.

purcell avatar Mar 24 '22 18:03 purcell