From f7134990bd9551d6361fb57db7095fa3bf44e092 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Tue, 9 Feb 2016 08:57:27 -0800 Subject: Fix #430: edit -f fails with UnknownPackageError - Recent external repo refactoring made `repo_for_pkg` raise an error when the package was not known. - Correct behavior is to return the highest precedence repo. --- lib/spack/spack/repository.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/repository.py b/lib/spack/spack/repository.py index b5df1168b6..f58cd52125 100644 --- a/lib/spack/spack/repository.py +++ b/lib/spack/spack/repository.py @@ -300,8 +300,11 @@ class RepoPath(object): for repo in self.repos: if spec.name in repo: return repo - else: - raise UnknownPackageError(spec.name) + + # If the package isn't in any repo, return the one with + # highest precedence. This is for commands like `spack edit` + # that can operate on packages that don't exist yet. + return self.first_repo() @_autospec -- cgit v1.2.3-60-g2f50