summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>2021-12-15 22:56:54 -0800
committerMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-12-23 16:02:09 +0100
commit314867e6358377d6a46de442bb04314f75959e25 (patch)
tree324d342ff693364453fd56a88d63d151f951b9ea /lib
parent9345bf81b95641a4e9728664f87777ed05f56b8f (diff)
downloadspack-314867e6358377d6a46de442bb04314f75959e25.tar.gz
spack-314867e6358377d6a46de442bb04314f75959e25.tar.bz2
spack-314867e6358377d6a46de442bb04314f75959e25.tar.xz
spack-314867e6358377d6a46de442bb04314f75959e25.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.py23
-rw-r--r--lib/spack/spack/test/cmd/install.py12
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