From ad1382e66491a1e9340e506c85a5f195c9c30a5b Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Sun, 25 Jun 2017 22:42:38 -0500 Subject: [PATCH] Don't immediately raise an error when an editor is not found (#4587) * Don't immediately raise an error when an editor is not found * If no editor is found, raise an error only if we try to use it. --- lib/spack/spack/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/spack/spack/__init__.py b/lib/spack/spack/__init__.py index 1f583fff61e..e77a0c75cdf 100644 --- a/lib/spack/spack/__init__.py +++ b/lib/spack/spack/__init__.py @@ -223,12 +223,13 @@ else: editor = which('vim', 'vi', 'emacs', 'nano') +# If there is no editor, only raise an error if we actually try to use it. if not editor: - default = default_editors[0] - msg = 'Default text editor, {0}, not found.\n'.format(default) - msg += 'Please set the EDITOR environment variable to your preferred ' - msg += 'text editor, or install {0}.'.format(default) - raise EnvironmentError(msg) + def editor_not_found(*args, **kwargs): + raise EnvironmentError( + 'No text editor found! Please set the EDITOR environment variable ' + 'to your preferred text editor.') + editor = editor_not_found from spack.package import \ install_dependency_symlinks, flatten_dependencies, \