diff --git a/swh/fuse/cli.py b/swh/fuse/cli.py --- a/swh/fuse/cli.py +++ b/swh/fuse/cli.py @@ -66,23 +66,27 @@ if not config_file: config_file = DEFAULT_CONFIG_PATH - try: - conf = config.read_raw_config(config.config_basepath(config_file)) - if not conf: - raise ValueError(f"Cannot parse configuration file: {config_file}") - - if config_file == DEFAULT_CONFIG_PATH: - try: - conf = conf["swh"]["fuse"] - except KeyError: - pass - - # recursive merge not done by config.read - conf = config.merge_configs(DEFAULT_CONFIG, conf) - except Exception: - logging.warning( - "Using default configuration (cannot load custom one)", exc_info=True - ) + if os.path.isfile(config_file): + try: + conf = config.read_raw_config(config.config_basepath(config_file)) + if not conf: + raise ValueError(f"Cannot parse configuration file: {config_file}") + + if config_file == DEFAULT_CONFIG_PATH: + try: + conf = conf["swh"]["fuse"] + except KeyError: + pass + + # recursive merge not done by config.read + conf = config.merge_configs(DEFAULT_CONFIG, conf) + except Exception: + logging.warning( + "Using default configuration (cannot load custom one)", exc_info=True + ) + conf = DEFAULT_CONFIG + else: + logging.info("Using default configuration") conf = DEFAULT_CONFIG logging.debug("Read configuration: \n%s", yaml.dump(conf))