include directive relative to file broken in 1.50.3
In ~/.hledger.journal I have:
!include doc/private/money/hledger.journal
That worked with versions up to 1.32.3, but not with hledger 1.50.3 (linux-x86_64):
joey@darkstar:~>hledger bal hledger: Error: /home/joey/.hledger.journal:3:2: | 3 | !include doc/private/money/hledger.journal | ^ No files were matched by glob pattern: doc/private/money/hledger.journal
To get it to work I had to prefix the path with "~/".
According to the documentation, include paths are supposed to be relative to the including file's folder. So for ~/.hledger.journal, paths should be relative to the home directory.
BTW, --old-glob does not change this behavior.
@joeyh, thanks for the report. I'm having trouble reproducing it so far.
~$ cat .hledger.journal
include doc/private/money/hledger.journal
~$ hledger-1.50.3 files
/Users/simon/.hledger.journal
/Users/simon/doc/private/money/hledger.journal
~$ hledger-1.50.3 print
2025-11-23 hledger.journal
~$ hledger-1.50.3 --version
hledger 1.50.3-g34bfcd596-20251118, mac-aarch64
I also tried making doc a git repo, and adding private to .gitignore there, just in case. I've tested on a mac and on a debian machine. (The ! is very old deprecated Ledger syntax; I tried with that too.)
Is there anything of interest if you add --debug=9 ? (after "readJournalFiles:")
Is one of these a symbolic link ? It seems the new glob ignores these too. https://github.com/Deewiant/glob/issues/48
Actually I'm confused about the symlink support. My tests seem to show it working, except for a symlink to a dot directory (or more generally to a path that includes a dot dir or dot file, perhaps). That's still my best guess at what could cause what you've reported.
I have just pushed a few commits to master, adding tests and some fixes for include's globs, and this commit message:
fix:journal:include: fix some regressions with glob matching in 1.50-1.50.3 Before 1.50, journal's include directive's handling of glob patterns (*, **, ?, etc.) had these limitations:
- ** always searched intermediate dot directories
- ** matched only directories, not files
In 1.50-1.50.3, it had different limitations, some unintended:
- it ignored all dot files, dot dirs, and symbolic links to dot dirs, even when explicitly mentioned in the pattern (unless using --old-glob)
- it showed symbolic links dereferenced, eg in
hledger filesoutputNow it has fewer limitations, mainly this:
- it ignores all dot files and dot dirs, even when explicitly mentioned (unless using --old-glob)
Ie it no longer ignores symbolic links to dot dirs, and it no longer shows symbolic links dereferenced. Also: including the current file is now always harmless, whether using a glob pattern or not.
Internally, file paths in the "include file stack" (jincludefilestack) are now just absolute, but not canonicalised; showing symbolic links un-dereferenced in output and error messages seems generally more useful. This might affect output elsewhere also. (Those paths are still canonicalised on the fly when checking for include cycles, not so efficiently: each time an include directive is parsed, all the current parent files and all the new glob-matched include files will be re-canonicalised. Hopefully this is unnoticeable.)
@joeyh I wonder if this makes any difference. I'll be shipping a release soon so if your problem is persisting do let me know.
I feel sure this is resolved after either the update above or today's fix for #2498; closing.
My ~/.hledger.journal is a symlimk to .etc/.hledger.journal
Sorry I didn't see the comments, but I think you figured it out despite my lack of followup.
Excellent - yet, I still have not managed to reproduce this.
But I did find this possibly similar regression, call it 2499b, in 1.50.4 and 1.51, caused by the recent changes (joy!):
$ ls -lRf symlink-to-relative-include.j etc
lrwxr-xr-x@ 1 simon staff 7 Dec 6 11:07 symlink-to-relative-include.j -> etc/a.j
etc:
total 24
drwxr-xr-x@ 5 simon staff 160 Dec 6 11:07 .
drwxr-xr-x@ 21 simon staff 672 Dec 6 11:07 ..
-rw-r--r--@ 1 simon staff 15 Dec 6 11:07 foo.j
-rw-r--r--@ 1 simon staff 14 Dec 6 11:07 a.j
$ cat etc/a.j
include foo.j
$ hledger-1.43.2 -f symlink-to-relative-include.j files
/Users/simon/src/hledger/hledger/test/journal/include/symlink-to-relative-include.j
/Users/simon/src/hledger/hledger/test/journal/include/etc/foo.j
$ hledger-1.50.3 -f symlink-to-relative-include.j files
/Users/simon/src/hledger/hledger/test/journal/include/symlink-to-relative-include.j
/Users/simon/src/hledger/hledger/test/journal/include/etc/foo.j
$ hledger-1.50.4 -f symlink-to-relative-include.j files
hledger-1.50.4: Error: /Users/simon/src/hledger/hledger/test/journal/include/symlink-to-relative-include.j:1:1:
|
1 | include foo.j
| ^
No files were matched by: foo.j
Tracking that one separately as #2503.