diff options
author | Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> | 2021-12-15 22:56:54 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-15 22:56:54 -0800 |
commit | ac49ce8b3ba0e1ef64d8a9a63cef0e2dad60b0de (patch) | |
tree | 35b3a7047e744e7bfc65a38b6a991254d0ee38e8 /lib | |
parent | 924061492839d385a2fdaaba213928bb0198b746 (diff) | |
download | spack-ac49ce8b3ba0e1ef64d8a9a63cef0e2dad60b0de.tar.gz spack-ac49ce8b3ba0e1ef64d8a9a63cef0e2dad60b0de.tar.bz2 spack-ac49ce8b3ba0e1ef64d8a9a63cef0e2dad60b0de.tar.xz spack-ac49ce8b3ba0e1ef64d8a9a63cef0e2dad60b0de.zip |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/install.py | 23 | ||||
-rw-r--r-- | 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 |