unclear error messages when config file contains a bad command argument
i have directly downloaded the hledger binary from github with version 1.50.2
when binary is run on my arch linux , it is giving the following error before exiting :
Error: command is not recognized. Run with no command to see a list.
my previous hledger version before upgrade, i.e 1.32.3 is running without any such error.
Can you check/show the output of hledger setup ?
following is the output of hledger setup
Checking your hledger setup.. Legend: good, neutral, unknown, warning
hledger
- is a released version ? yes hledger 1.50.2, linux-x86_64
- is up to date ? yes 1.50.2 installed, latest is 1.50.2
- is a native binary for this machine ? yes x86_64
- is installed in PATH (this version) ? yes ./hledger
- has a system text encoding configured ? yes UTF-8, data files must use this encoding
- has a user config file ? yes /home/xxxx/.config/hledger/hledger.conf
- has a local config file ? no
- the config file is readable ? yes
terminal
- the NO_COLOR variable is defined ? no
- --color is configured by config file ? no
- hledger will use color by default ? yes
- the PAGER variable is defined ? yes /home/xxxx/.local/bin/moar2
- --pager is configured by config file ? no
- hledger will use a pager when needed ? yes /home/xxxx/.local/bin/moar2
- tables will use box-drawing chars ? yes
journal
- the LEDGER_FILE variable is defined ? yes /home/xxxx/AccountCli/ledgercli/data/2025/cash.ledger
- a default journal file is readable ? yes /home/xxxx/AccountCli/ledgercli/data/2025/cash.ledger
- it includes additional files ? yes 35 files
- all commodities are declared ? yes 1 commodities
- all accounts are declared ? yes 162 accounts
- all accounts have types ? yes
- all account types are detected ? no V not found; bs/cf/is reports may not work
- commodities/accounts are being checked ? no you can use -s to check them
- balance assertions are being checked ? no you can use -s to check them
It sounds like a problem in your config file .config/hledger/hledger.conf. See if running with -n fixes it, and share the config file if you'd like (or let us know what problem you found there).
I can reproduce like this: add an unrecognized command argument in the general section of a config file:
# .hledger.conf
foo
Then run hledger with no arguments:
$ hledger
hledger: Error: command is not recognized. Run with no command to see a list.
Problem: it should mention "foo" as the command name.
Also if you add a valid command on the command line:
$ hledger bal
hledger: Error: command bal is not recognized. Run with no command to see a list.
Problem: this message is misleading, obscuring the problem.
Workaround: fix or remove your config file.
Thanks for reporting.