From 1e386c3780254a3a59c540efb5bd77746f67c98c Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Thu, 6 Nov 2025 15:10:34 +0100 Subject: [PATCH] libstore: add usage hints to repairPath on daemons we can't change the protocol to allow daemons to do this, and we should not try to guess what the `auto` store uri means depending on whether a command was run by root or not due to copious side effects and not even being able to tell whether the `auto` store uri was given explicitly or not. while `auto` may *technically* allow this via its naming we should resist the urge to add a hack and fix the underlying protocols instead, especially since repairPath should be a rare, superuser only operation. fixes #888 Change-Id: I1b53245db226199f827a89a237a2ab9907c3f766 --- lix/libstore/store-api.hh | 13 ++++++++++--- lix/libstore/uds-remote-store.hh | 10 ++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lix/libstore/store-api.hh b/lix/libstore/store-api.hh index c3a5a1d10..0ed598700 100644 --- a/lix/libstore/store-api.hh +++ b/lix/libstore/store-api.hh @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -927,11 +928,17 @@ protected: * \todo Using this should be a last resort. It is better to make * the method "virtual pure" and/or move it to a subclass. */ - [[noreturn]] void unsupported(const std::string & op) + [[noreturn]] + void + unsupported(const std::string & op, const std::optional info = std::nullopt) { - throw Unsupported("operation '%s' is not supported by store '%s'", op, getUri()); + throw Unsupported( + "operation '%s' is not supported by store '%s'%s", + op, + getUri(), + Uncolored(info ? fmt(". %s", *info) : "") + ); } - }; diff --git a/lix/libstore/uds-remote-store.hh b/lix/libstore/uds-remote-store.hh index 5f355a18a..a6cb74710 100644 --- a/lix/libstore/uds-remote-store.hh +++ b/lix/libstore/uds-remote-store.hh @@ -49,6 +49,16 @@ public: return LocalFSStore::narFromPath(path, context); } + kj::Promise> repairPath(const StorePath & path) override + try { + unsupported( + "repairPath", + HintFmt("This command must be run as %s with %s", "root", "--store local").str() + ); + } catch (...) { + return {result::current_exception()}; + } + /** * Implementation of `IndirectRootStore::addIndirectRoot()` which * delegates to the remote store.