about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/nix/search.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nix/search.cc b/src/nix/search.cc
index 87cdb2d7ed8a..1adde28cb3ca 100644
--- a/src/nix/search.cc
+++ b/src/nix/search.cc
@@ -237,7 +237,7 @@ struct CmdSearch : SourceExprCommand, MixJSON
                     throw Error("error writing to %s", tmpFile);
             }
 
-            if (rename(tmpFile.c_str(), jsonCacheFileName.c_str()) == -1)
+            if (writeCache && rename(tmpFile.c_str(), jsonCacheFileName.c_str()) == -1)
                 throw SysError("cannot rename '%s' to '%s'", tmpFile, jsonCacheFileName);
         }
     }