From 314867e6358377d6a46de442bb04314f75959e25 Mon Sep 17 00:00:00 2001 From: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> Date: Wed, 15 Dec 2021 22:56:54 -0800 Subject: Provide meaningful message for empty environment installs (#28031) * Provide a meaningful failure message for installation of an empty environment * Allow regenerating view per offline discussion --- lib/spack/spack/cmd/install.py | 23 ++++++++++++++--------- lib/spack/spack/test/cmd/install.py | 12 ++++++++++++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py index 95b195bc53..f4a4644312 100644 --- a/lib/spack/spack/cmd/install.py +++ b/lib/spack/spack/cmd/install.py @@ -348,17 +348,22 @@ environment variables: env.write(regenerate=False) specs = env.all_specs() - if not args.log_file and not reporter.filename: - reporter.filename = default_log_file(specs[0]) - reporter.specs = specs + if specs: + if not args.log_file and not reporter.filename: + reporter.filename = default_log_file(specs[0]) + reporter.specs = specs - # Tell the monitor about the specs - if args.use_monitor and specs: - monitor.new_configuration(specs) + # Tell the monitor about the specs + if args.use_monitor and specs: + monitor.new_configuration(specs) - tty.msg("Installing environment {0}".format(env.name)) - with reporter('build'): - env.install_all(**kwargs) + tty.msg("Installing environment {0}".format(env.name)) + with reporter('build'): + env.install_all(**kwargs) + + else: + msg = '{0} environment has no specs to install'.format(env.name) + tty.msg(msg) tty.debug("Regenerating environment views for {0}" .format(env.name)) diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py index 4fa022d168..2c79880088 100644 --- a/lib/spack/spack/test/cmd/install.py +++ b/lib/spack/spack/test/cmd/install.py @@ -1099,3 +1099,15 @@ def test_install_env_with_tests_root(tmpdir, mock_packages, mock_fetch, add('depb') install('--test', 'root') assert not os.path.exists(test_dep.prefix) + + +def test_install_empty_env(tmpdir, mock_packages, mock_fetch, + install_mockery, mutable_mock_env_path): + env_name = 'empty' + env('create', env_name) + with ev.read(env_name): + out = install(fail_on_error=False) + + assert env_name in out + assert 'environment' in out + assert 'no specs to install' in out -- cgit v1.2.3-70-g09d2