diff --git a/src/python/pants/base/build_file.py b/src/python/pants/base/build_file.py
index 1da8188..59cccf8 100644
--- a/src/python/pants/base/build_file.py
+++ b/src/python/pants/base/build_file.py
@@ -38,6 +38,10 @@ class BuildFile(AbstractClass):
"""Raised when the root_dir specified to a BUILD file is not valid."""
pass
+ class BadPathError(BuildFileError):
+ """Raised when scan_buildfiles is called on a nonexistent directory."""
+ pass
+
_BUILD_FILE_PREFIX = 'BUILD'
_PATTERN = re.compile('^{prefix}(\.[a-zA-Z0-9_-]+)?$'.format(prefix=_BUILD_FILE_PREFIX))
@@ -104,6 +108,10 @@ class BuildFile(AbstractClass):
to_remove.append(subdir)
return to_remove
+ if base_path and not cls._isdir(os.path.join(root_dir, base_path)):
+ raise cls.BadPathError('Can only scan directories and {0} is not a valid dir'
+ .format(base_path))
+
buildfiles = []
if not spec_excludes:
exclude_roots = {}
@@