bitcoin: Bitcoin ignores datadir and blocksdir parameter in .conf
Is there an existing issue for this?
- Similar questions was raised in #15745 but it is marked as “solved” and closed.
Current behaviour
Registry has a REG_SZ key HKEY_CURRENT_USER\SOFTWARE\Bitcoin\Bitcoin-Qt\strDataDir
(and there can be Bitcoin-Qt-regtest\strDataDir, Bitcoin-Qt-testnet\strDataDir for test chains).
It is created by default when bitcoin-qt starts first time and after editing/accepting first start wizard.
Change database directory to non-default path, put there bitcoin.conf with datadir=databasepath and run bitcoin-qt (-cli/etc) and bitcoin ignores datadir path if no -datadir argument passed to a program exclusively.
The same problem with the blocksdir parameter.
Expected behaviour
In all situations behavior must be identical - if we start without arguments or pass “-conf” then use .conf “datadir=path” (according to sections [main], [regtest], [test] or global if there are no sections) if .conf exists and datadir are there. Now it is ignored. If we start with “-datadir=path” argument it’s works.
Steps to reproduce
- For example, change
HKEY_CURRENT_USER\SOFTWARE\Bitcoin\Bitcoin-Qt\strDataDir
toW:\BitcoinCore\strDataDir
(assuming our disk is W: and all paths in this example exists). - Create W:\BitcoinCore\strDataDir\bitcoin.conf with three lines:
datadir=W:/BitcoinCore/DataDir/main1 [main] datadir=W:/BitcoinCore/DataDir/main2
- Start
bitcoin-qt.exe -debuglogfile=W:/BitcoinCore/debug.no_params.log
- After a few seconds close opened wallet (bitcoin-qt) [Alt-F4].
- Start
bitcoin-qt.exe -datadir=W:\BitcoinCore\DataDir\main -debuglogfile=W:\BitcoinCore\debug.w_datadir_param.log
- After a few seconds close opened wallet (bitcoin-qt) [Alt-F4].
- Start
bitcoin-qt.exe -conf=W:\BitcoinCore\strDataDir\bitcoin.conf -debuglogfile=W:\BitcoinCore\debug.w_conf_param.log
- After a few seconds close opened wallet (bitcoin-qt) [Alt-F4].
- Check filesystem and logs (attached).
I’ve used Sysinternals Process Monitor to dig what’s happening.
Relevant log output
debug.no_params.log:
Default data directory C:\Users\USERNAME\AppData\Roaming\Bitcoin Using data directory W:\BitcoinCore\strDataDir Config file: W:\BitcoinCore\strDataDir\bitcoin.conf Config file arg: datadir=“W:/BitcoinCore/DataDir/main1” Config file arg: [main] datadir=“W:/BitcoinCore/DataDir/main2” Creating peers.dat because the file was not found (“W:\BitcoinCore\strDataDir\peers.dat”) Opening LevelDB in W:\BitcoinCore\strDataDir\blocks\index Opening LevelDB in W:\BitcoinCore\strDataDir\chainstate
debug.w_datadir_param.log:
Default data directory C:\Users\USERNAME\AppData\Roaming\Bitcoin Using data directory W:\BitcoinCore\DataDir\main Config file: W:\BitcoinCore\DataDir\main\bitcoin.conf (not found, skipping) Command-line arg: datadir=“W:\\BitcoinCore\\DataDir\\main” Opening LevelDB in W:\BitcoinCore\\DataDir\main\blocks\index Opening LevelDB in W:\BitcoinCore\DataDir\main\chainstate
debug.w_conf_param.log output is identical to debug.no_params.log.
How did you obtain Bitcoin Core
- Downloaded from bitcoincore.org/bin
- Compiled from source
What version of Bitcoin Core are you using?
24.0.1
Operating system and version
Win 10 x64
Machine specifications
Non relevant
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 26 (15 by maintainers)
Commits related to this issue
- Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could happe... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could happe... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could happe... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- init: Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- init: Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- init: Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- init: Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- init: Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- init: Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- init: Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- init: Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- init: Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- init: Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- init: Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could... — committed to ryanofsky/bitcoin by ryanofsky a year ago
- Merge bitcoin/bitcoin#27302: init: Error if ignored bitcoin.conf file is found eefe56967b4eb4b5144325cde4f40fc1cbde3e65 bugfix: Fix incorrect debug.log config file path (Ryan Ofsky) 3746f00be1b732a04... — committed to bitcoin-core/gui by fanquake a year ago
- init: Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could... — committed to luke-jr/bitcoin by ryanofsky a year ago
- init: Error if ignored bitcoin.conf file is found Show an error on startup if a bitcoin datadir that is being used contains a `bitcoin.conf` file that is ignored. There are two cases where this could... — committed to BitgesellOfficial/bitgesell by ryanofsky a year ago
The issue with bitcoind described https://github.com/bitcoin/bitcoin/issues/27246#issuecomment-1470006043 is that a config file specifying a datadir which contains a second config file will ignore the second config file with no warning. I outlined three solutions for this issue here: https://github.com/bitcoin/bitcoin/issues/27246#issuecomment-1470284856 and implemented the third solution in a branch here: https://github.com/bitcoin/bitcoin/compare/master...ryanofsky:bitcoin:pr/ignoredconf
I haven’t posted a PR yet because I’m working on a python test which is a little tricky to implement.
EDIT: This is now posted as #27302