about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/local-store.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 3c367c080815..4ac7d7f4e6f7 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -354,10 +354,14 @@ int LocalStore::getSchema()
 
 void LocalStore::openDB(bool create)
 {
+    if (access(settings.nixDBPath.c_str(), R_OK | W_OK))
+        throw SysError(format("Nix database directory `%1%' is not writable") % settings.nixDBPath);
+
     /* Open the Nix database. */
-    if (sqlite3_open_v2((settings.nixDBPath + "/db.sqlite").c_str(), &db.db,
+    string dbPath = settings.nixDBPath + "/db.sqlite";
+    if (sqlite3_open_v2(dbPath.c_str(), &db.db,
             SQLITE_OPEN_READWRITE | (create ? SQLITE_OPEN_CREATE : 0), 0) != SQLITE_OK)
-        throw Error("cannot open SQLite database");
+        throw Error(format("cannot open Nix database `%1%'") % dbPath);
 
     if (sqlite3_busy_timeout(db, 60 * 60 * 1000) != SQLITE_OK)
         throwSQLiteError(db, "setting timeout");