diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 158d76e568720b85d168cc323c8ee65fe1da187a..c92594da7263485e433cbd782ee60ee9f49b8f03 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -531,8 +531,9 @@ def __getattr__(self, item):
         """Delegate to self.package if the attribute is not in the spec"""
         # This line is to avoid infinite recursion in case package is
         # not present among self attributes
-        package = super(Spec, self).__getattribute__('package')
-        return getattr(package, item)
+        if item.endswith('libs'):
+            return getattr(self.package, item)
+        raise AttributeError()
 
     def get_dependency(self, name):
         dep = self._dependencies.get(name)