-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Description
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/code/bitcoin_testinbox$ bitcoin server starting
candide@candide-VirtualBox:candide@candide-VirtualBox:~/code/bitcoin_testinbox$ Warning: To use the "-daemon" option, you must set rpcpassword=
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/code/bitcoin_testinbox$
candide@candide-VirtualBox:
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.