Specifying -datadir= to a non existent path creates directories or fails to stderr #337

issue jburkle opened this issue on June 21, 2011
  1. jburkle commented at 3:18 AM on June 21, 2011: contributor

    I experienced this while testing out testnet-in-a-box. If I specify a path to a directory that does not exist, but is 1 directory level lower than an actual path, I get a "missing bitcoin.conf" error:

    candide@candide-VirtualBox:~/code/bitcoin_testinbox$ bitcoin -datadir=/home/candide/code/bitcoin_testinbox/asdf/ -daemon candide@candide-VirtualBox:~/code/bitcoin_testinbox$ bitcoin server starting

    candide@candide-VirtualBox:~/code/bitcoin_testinbox$ Warning: To use the "-daemon" option, you must set rpcpassword=<password> in the configuration file: /home/candide/code/bitcoin_testinbox/asdf/bitcoin.conf If the file does not exist, create it with owner-readable-only file permissions.

    10:58:06 PM: Debug: In file ./src/unix/threadpsx.cpp at line 253: 'pthread_mutex_destroy()' failed with error 0x00000010 (Device or resource busy).

    Also, the program actually creates the non existent directory.

    Additionally, If I specify a path more than 1 directory level lower than an existing path, I get a much more verbose error to stderr:

    candide@candide-VirtualBox:~/code/bitcoin_testinbox$ bitcoin -datadir=/home/candide/code/bitcoin_testinbox/asdf/new/dir -daemon candide@candide-VirtualBox:~/code/bitcoin_testinbox$


    EXCEPTION: N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_10filesystem22basic_filesystem_errorINS3_10basic_pathISsNS3_11path_traitsEEEEEEEEE
    boost::filesystem::create_directory: No such file or directory: "/home/candide/code/bitcoin_testinbox/asdf/new/dir"
    bitcoin in AppInit()


    EXCEPTION: >N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_10filesystem22basic_filesystem_errorINS3_10basic_pathISsNS3_11path_traitsEEEEEEEEE
    boost::filesystem::create_directory: No such file or directory: "/home/candide/code/bitcoin_testinbox/asdf/new/dir"
    bitcoin in CMyApp::OnUnhandledException()

    terminate called after throwing an instance of '>boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::filesystem::basic_filesystem_error<boost::filesystem::basic_path<std::string, boost::filesystem::path_traits> > > >' what(): boost::filesystem::create_directory: No such file or directory: "/home/candide/code/bitcoin_testinbox/asdf/new/dir"

    I have some thoughts on this. Number 1, the code should check if the datadir being specified actually exists before it continues. If the datadir does not exist, the program should probably exit with a "specified datadir does not exist" error. Further, when passing the -daemon flag, the bitcoin program should create a log file automatically in the datadir directory, or allow a -logdir at the command line (if one is not specified, default to datadir for logdir, or syslog, or anything other than screen dumps). All stderr should be directed to the log file instead of the terminal.

  2. jgarzik commented at 4:43 AM on June 24, 2011: contributor

    merging your pull for this...

  3. jgarzik closed this on Jun 24, 2011

  4. ptschip referenced this in commit acc32ffab5 on Mar 7, 2017
  5. ptschip referenced this in commit 3f9a8f631b on Apr 24, 2017
  6. classesjack referenced this in commit 5e090b533d on Jan 2, 2018
  7. sipa referenced this in commit 6b9cd1520b on Sep 24, 2019
  8. sipa referenced this in commit 544c1f35e7 on Nov 6, 2019
  9. sipa referenced this in commit d5cd9db7a3 on Nov 19, 2019
  10. attilaaf referenced this in commit a7cadc0a64 on Jan 13, 2020
  11. sipa referenced this in commit de659898b6 on Jan 21, 2020
  12. sipa referenced this in commit 36362dfb90 on Jan 23, 2020
  13. jnewbery referenced this in commit 85e7d06351 on Mar 17, 2020
  14. sipa referenced this in commit 4977ac14d3 on Mar 18, 2020
  15. sipa referenced this in commit 5bf7fb5baa on Mar 18, 2020
  16. sipa referenced this in commit fb2a05e468 on Mar 19, 2020
  17. sipa referenced this in commit 497fad6f09 on Mar 21, 2020
  18. sipa referenced this in commit eae016f117 on Mar 22, 2020
  19. sipa referenced this in commit 4e37a7c2cb on Mar 27, 2020
  20. jnewbery referenced this in commit 9696dea839 on Apr 16, 2020
  21. jnewbery referenced this in commit a541fd0e87 on Apr 19, 2020
  22. sipa referenced this in commit c308759ea5 on Apr 19, 2020
  23. sipa referenced this in commit 4eaec32f1c on May 2, 2020
  24. sipa referenced this in commit ef7117193c on May 22, 2020
  25. sipa referenced this in commit 67f232b5d8 on Jun 9, 2020
  26. stackman27 referenced this in commit 78cde6f8c7 on Jun 26, 2020
  27. bitcoin locked this on Sep 8, 2021
Contributors

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-05-19 14:56 UTC

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