Handle exception when creating default -datadir #15871

pull promag wants to merge 1 commits into bitcoin:master from promag:2019-04-default-datadir changing 1 files +5 −2
  1. promag commented at 11:38 PM on April 22, 2019: member

    To test determine the default -datadir by following: https://github.com/bitcoin/bitcoin/blob/08bd21a3bda9f621948c535e951880d7e318caa5/src/util/system.cpp#L687-L690 Then, for instance, on linux:

    # create a file with that path:
    touch ~/.bitcoin
    # launch daemon:
    src/bitcoind
    

    Without this PR:

    EXCEPTION: N5boost10filesystem16filesystem_errorE
    boost::filesystem::create_directory: File exists: "..."
    bitcoin in AppInit()
    
    Assertion failed: (globalChainBaseParams), function BaseParams, file chainparamsbase.cpp, line 30.
    
  2. Handle exception when creating default -datadir f5e69b2fae
  3. fanquake added the label Utils/log/libs on Apr 22, 2019
  4. practicalswift commented at 11:49 AM on April 23, 2019: contributor

    Concept ACK

  5. hebasto commented at 3:55 PM on April 23, 2019: member

    Tested on Linux:

    $ touch ~/.bitcoin
    $ src/bitcoind
    Error: Specified data directory "" does not exist.
    

    ... not very informative ;)

  6. hebasto commented at 4:15 PM on April 23, 2019: member

    As PR #15864 and this one are related to each other I've tested both combined:

    $ touch ~/.bitcoin
    $ src/bitcoind
    2019-04-23T16:09:54Z Bitcoin Core version v0.18.99.0-9a45f351e (release build)
    2019-04-23T16:09:54Z 
    
    ************************
    EXCEPTION: N5boost10filesystem16filesystem_errorE       
    boost::filesystem::create_directory: Not a directory: "/home/hebasto/.bitcoin/blocks"       
    bitcoin in AppInit()       
    
    
    
    ************************
    EXCEPTION: N5boost10filesystem16filesystem_errorE       
    boost::filesystem::create_directory: Not a directory: "/home/hebasto/.bitcoin/blocks"       
    bitcoin in AppInit()       
    
    2019-04-23T16:09:54Z Shutdown: In progress...
    2019-04-23T16:09:54Z Shutdown: Unable to remove PID file: File does not exist
    2019-04-23T16:09:54Z Shutdown: done
    
  7. promag commented at 2:20 PM on April 26, 2019: member

    Tested on Linux:

    $ touch ~/.bitcoin
    $ src/bitcoind
    Error: Specified data directory "" does not exist.
    

    ... not very informative ;)

    Do you suggest a specific message?

  8. hebasto commented at 2:26 PM on April 26, 2019: member

    Do you suggest a specific message?

    I mean the default datadir has a name, not an empty string.

  9. promag commented at 10:14 AM on April 28, 2019: member

    Now printing the effective data dir:

    $ src/bitcoind
    Error: Specified data directory "" (/Users/joao/Library/Application Support/Bitcoin) does not exist.
    
  10. hebasto commented at 10:23 AM on April 28, 2019: member

    Concept ACK.

  11. hebasto commented at 10:36 AM on April 28, 2019: member

    @promag what is the motivation to use an error code rather a try...catch block? The developer notes say nothing about such policy.

  12. promag commented at 10:43 AM on April 28, 2019: member

    None really. That would make a bigger diff at least.

  13. hebasto commented at 10:43 AM on April 28, 2019: member

    Tested on Linux:

    $ touch ~/.bitcoin
    $ src/bitcoind
    Error: Specified data directory "" (/home/hebasto/.bitcoin) does not exist.
    
    $ src/bitcoind -datadir=/home/hebasto/non-exist-dir
    Error: Specified data directory "/home/hebasto/non-exist-dir" () does not exist.
    

    IMO, using different notation (quotes "..." and parentheses (...)) is a bit confusing ;)

  14. DrahtBot commented at 11:45 AM on April 28, 2019: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  15. promag force-pushed on Apr 29, 2019
  16. promag commented at 3:37 PM on April 29, 2019: member

    Reverting to previous version. GetDataDir is a mess because it doesn't always give the effective path. Considering this an edge case I don't think it's worth a bigger refactor.

  17. laanwj commented at 1:52 PM on September 10, 2019: member

    before:

    
    ************************
    EXCEPTION: N5boost10filesystem16filesystem_errorE       
    boost::filesystem::create_directory: File exists: "/…/.bitcoin"       
    bitcoin in AppInit()       
    
    bitcoind: /home/orion/projects/bitcoin/bitcoin/src/chainparamsbase.cpp:32: const CBaseChainParams& BaseParams(): Assertion `globalChainBaseParams' failed.
    Aborted (core dumped)
    

    after:

    ************************
    EXCEPTION: N5boost10filesystem16filesystem_errorE       
    boost::filesystem::create_directory: Not a directory: "…/.bitcoin/blocks"       
    bitcoin in AppInit()       
    

    not convinced that this is much of an improvement in error reporting

  18. laanwj commented at 12:21 PM on September 30, 2019: member

    I'm closing this, I don't think it's enough of an improvement.

  19. laanwj closed this on Sep 30, 2019

  20. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me