Skip to content

Relative paths named in the -conf parameter reset when parsing datadir in named config #19990

@brianddk

Description

@brianddk

When naming a configuration file using a relative path using the -conf command line parameter, the configuration parser will present an error if the datadir option is listed in the named configuration file. The configuration parser will expect the named config file in both the default datadir and the named datadir.

For example. Given the config file named usb.conf with the contents:

# Bitcoin Config file: %APPDATA%\Bitcoin\usb.conf
datadir=D:\Bitcoin

And calling bitcoin with the following "%PROGRAMFILES%\Bitcoin\Bitcoin-qt.exe" -conf=usb.conf the config parser will present an error if D:\Bitcoin\usb.conf does not exist. Clearly it has found and parsed %APPDATA%\Bitcoin\usb.conf but yet it still needs to parse D:\Bitcoin\usb.conf

Expected behavior

Command line arguments should trump config file arguments. So since -datadir is not specified on the command line, the location for the named config file should correctly resolve to %APPDATA%\Bitcoin\usb.conf without further dependencies on D:\Bitcoin\usb.conf. Once the initial path location is resolved, it should not be reevaluated. This is understandably a "special case". Normally relative paths are resolved from datadir, but the -conf parameter is already special in the sense that is not supported in the config file parsing, so should not be influenced by what is parsed from the config file.

Actual behavior

The config parser throws an error if the config file does not exist both in the default datadir and the named datadir

issue

Note, as a workaround, providing the full path to the config file mutes the error. This is only related to how relative paths are interpreted.

To reproduce

Completely reproducible

System information

  • Windows 10.0.18363 Build 18363
  • Precompiled 0.20.1 Windows x64 binaries landed from installer downloaded from bitcoin.org
  • Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz, 3001 Mhz, 4 Core(s), 4 Logical Processor(s)
  • Disk0: WDC WD10EZEX
  • Disk1: Generic USB mounted SSD
Expand for debug.log
2020-09-22T03:00:12Z Bitcoin Core version v0.20.1 (release build)
2020-09-22T03:00:12Z Qt 5.9.8 (static), plugin=windows (static)
2020-09-22T03:00:12Z System: Windows 10 (10.0), x86_64-little_endian-llp64
2020-09-22T03:00:12Z Screen: \\.\DISPLAY1 1920x1080, pixel ratio=1.0
2020-09-22T03:00:12Z Assuming ancestors of block 000000000000056c49030c174179b52a928c870e6e8a822c75973b7970cfbd01 have valid signatures.
2020-09-22T03:00:12Z Setting nMinimumChainWork=0000000000000000000000000000000000000000000001495c1d5a01e2af8a23
2020-09-22T03:00:12Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
2020-09-22T03:00:12Z Using RdSeed as additional entropy source
2020-09-22T03:00:12Z Using RdRand as an additional entropy source
2020-09-22T03:00:12Z GUI: "registerShutdownBlockReason: Successfully registered: Bitcoin Core didn't yet exit safely..."
2020-09-22T03:00:12Z Default data directory C:\Users\{redacted}\AppData\Roaming\Bitcoin
2020-09-22T03:00:12Z Using data directory d:\Bitcoin\testnet3
2020-09-22T03:00:12Z Warning: The specified config file d:\Bitcoin\usb.conf does not exist
2020-09-22T03:00:14Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2020-09-22T03:00:14Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2020-09-22T03:00:14Z Script verification uses 3 additional threads
2020-09-22T03:00:14Z scheduler thread start
2020-09-22T03:00:14Z Using wallet directory d:\Bitcoin\testnet3\wallets
2020-09-22T03:00:14Z init message: Verifying wallet(s)...
2020-09-22T03:00:14Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2020-09-22T03:00:14Z Using wallet d:\Bitcoin\testnet3\wallets
2020-09-22T03:00:14Z BerkeleyEnvironment::Open: LogDir=d:\Bitcoin\testnet3\wallets\database ErrorFile=d:\Bitcoin\testnet3\wallets\db.log
2020-09-22T03:00:14Z init message: Loading banlist...
2020-09-22T03:00:14Z Using /16 prefix for IP bucketing
2020-09-22T03:00:14Z Cache configuration:
2020-09-22T03:00:14Z * Using 2.0 MiB for block index database
2020-09-22T03:00:14Z * Using 8.0 MiB for chain state database
2020-09-22T03:00:14Z * Using 440.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
2020-09-22T03:00:14Z init message: Loading block index...
2020-09-22T03:00:14Z Opening LevelDB in d:\Bitcoin\testnet3\blocks\index

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions