If we first check for datadir existence and then read the config file we bail out in situations where the default datadir is invalid, e.g. because of an non-existing HOME, but the datadir specified in config files is valid. We should not do that, as the user may specified a valid datadir in the config file and expects the setting to take effect.
See for example #12255 (comment) where users hit this.