about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libexpr/common-opts.cc4
-rw-r--r--src/libexpr/eval.hh2
-rw-r--r--src/libexpr/parser.y5
3 files changed, 6 insertions, 5 deletions
diff --git a/src/libexpr/common-opts.cc b/src/libexpr/common-opts.cc
index 0ee889a995..9b3421f6c4 100644
--- a/src/libexpr/common-opts.cc
+++ b/src/libexpr/common-opts.cc
@@ -13,7 +13,7 @@ bool parseOptionArg(const string & arg, Strings::iterator & i,
     if (arg != "--arg" && arg != "--argstr") return false;
 
     UsageError error(format("`%1%' requires two arguments") % arg);
-    
+
     if (i == argsEnd) throw error;
     string name = *i++;
     if (i == argsEnd) throw error;
@@ -39,7 +39,7 @@ bool parseSearchPathArg(const string & arg, Strings::iterator & i,
 {
     if (arg != "-I") return false;
     if (i == argsEnd) throw UsageError(format("`%1%' requires an argument") % arg);;
-    state.addToSearchPath(*i++);
+    state.addToSearchPath(*i++, true);
     return true;
 }
 
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index 5ae5a1e3cf..6da89c58a6 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -120,7 +120,7 @@ public:
     EvalState();
     ~EvalState();
 
-    void addToSearchPath(const string & s);
+    void addToSearchPath(const string & s, bool warn = false);
 
     /* Parse a Nix expression from the specified file. */
     Expr * parseExprFromFile(const Path & path);
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 8a084fea06..dc995db00d 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -608,7 +608,7 @@ Expr * EvalState::parseExprFromString(const string & s, const Path & basePath)
 }
 
 
-void EvalState::addToSearchPath(const string & s)
+ void EvalState::addToSearchPath(const string & s, bool warn)
 {
     size_t pos = s.find('=');
     string prefix;
@@ -624,7 +624,8 @@ void EvalState::addToSearchPath(const string & s)
     if (pathExists(path)) {
         debug(format("adding path `%1%' to the search path") % path);
         searchPath.insert(searchPathInsertionPoint, std::pair<string, Path>(prefix, path));
-    }
+    } else if (warn)
+        printMsg(lvlError, format("warning: Nix search path entry `%1%' does not exist, ignoring") % path);
 }