{"record":{"id":"02d39a103ac25203","repo":"microsoft/qlib","slug":"mount-failed-requires-sudo-or-permission-denied","errorCode":null,"errorMessage":"Mount failed: requires sudo or permission denied","messagePattern":"Mount failed: requires sudo or permission denied","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"warning","filePath":"qlib/__init__.py","lineNumber":179,"sourceCode":"                try:\n                    Path(mount_path).mkdir(parents=True, exist_ok=True)\n                except Exception as e:\n                    raise OSError(\n                        f\"Failed to create directory {mount_path}, please create {mount_path} manually!\"\n                    ) from e\n\n                # check nfs-common\n                command_res = os.popen(\"dpkg -l | grep nfs-common\")\n                command_res = command_res.readlines()\n                if not command_res:\n                    raise OSError(\"nfs-common is not found, please install it by execute: sudo apt install nfs-common\")\n                # manually mount\n                try:\n                    subprocess.run(mount_command, check=True, capture_output=True, text=True)\n                    LOG.info(\"Mount finished.\")\n                except subprocess.CalledProcessError as e:\n                    if e.returncode == 256:\n                        raise OSError(\"Mount failed: requires sudo or permission denied\") from e\n                    elif e.returncode == 32512:\n                        raise OSError(f\"mount {provider_uri} on {mount_path} error! Command error\") from e\n                    else:\n                        raise OSError(f\"Mount failed: {e.stderr}\") from e\n            else:\n                LOG.warning(f\"{_remote_uri} on {_mount_path} is already mounted\")\n\n\ndef init_from_yaml_conf(conf_path, **kwargs):\n    \"\"\"init_from_yaml_conf\n\n    :param conf_path: A path to the qlib config in yml format\n    \"\"\"\n\n    if conf_path is None:\n        config = {}\n    else:\n        with open(conf_path) as f:","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/__init__.py#L161-L197","documentation":"Base ExpressionCache._expression (qlib/data/cache.py:360) is the abstract method that actually reads expression data from the cache. The base raises NotImplementedError('Implement this method if you want to use expression cache'); the public expression() wrapper catches that NotImplementedError and transparently falls back to self.provider.expression(...), i.e. without a cache you silently pay the cost of loading from the underlying provider.","triggerScenarios":"Registering a custom ExpressionCache subclass without overriding _expression: data still loads (via provider fallback) but nothing is cached; calling _expression directly always raises; subclass forgot to also override _uri, in which case uri-related calls fail separately.","commonSituations":"Boilerplate custom cache classes where only the constructor was customized; misreading the API — assuming the base class provides a default file-based cache (it does not; that is DiskExpressionCache).","solutions":["Use the shipped qlib.data.cache.DiskExpressionCache if file-based caching is what you want","Override _expression(self, instrument, field, start_time, end_time, freq) -> pd.Series in your subclass to read from your cache backend","Pair it with _uri and update overrides — all three must be consistent"],"exampleFix":"# before\nqlib.init(expression_cache=MyBrokenCache)  # _expression not overridden -> no caching\n\n# after\nfrom qlib.data.cache import DiskExpressionCache\nqlib.init(expression_cache=DiskExpressionCache, expression_cache_disk_path=...)","handlingStrategy":"fallback","validationCode":"from qlib.data.cache import ExpressionCache\n\nif MyExprCache._expression is ExpressionCache._expression:\n    print(\"WARNING: expression cache disabled (falls back to provider)\")","typeGuard":null,"tryCatchPattern":"# expression() already falls back to the provider on NotImplementedError;\n# detect the silent no-cache path by timing or by checking cache dir growth","preventionTips":["Confirm cache files actually appear after runs; silent fallback makes caches a no-op","Base custom caches on DiskExpressionCache when possible","Alert when cache hit counters stay at zero"],"tags":["qlib","cache","custom-backend","not-implemented"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}