diff --git a/lib/spack/spack/cmd/buildcache.py b/lib/spack/spack/cmd/buildcache.py index 1d105a0c0d427ff697c1bbe2042a8fc3cb7dfd11..f837e6b8a3a96fb4c006f1fca1a0d2ebd3d26d28 100644 --- a/lib/spack/spack/cmd/buildcache.py +++ b/lib/spack/spack/cmd/buildcache.py @@ -366,13 +366,9 @@ def _createtarball(env, spec_yaml, packages, directory, key, no_deps, force, for spec in specs: tty.msg('creating binary cache file for package %s ' % spec.format()) - try: - bindist.build_tarball(spec, outdir, force, rel, - unsigned, allow_root, signkey, - not no_rebuild_index) - except Exception as e: - tty.warn('%s' % e) - pass + bindist.build_tarball(spec, outdir, force, rel, + unsigned, allow_root, signkey, + not no_rebuild_index) def createtarball(args): diff --git a/lib/spack/spack/test/cmd/buildcache.py b/lib/spack/spack/test/cmd/buildcache.py index 064daeb0636a93acc81e5ee1826456fc5b0f4cc3..03d09b9771ca0fb3a40807fb985a38a4c2c859a9 100644 --- a/lib/spack/spack/test/cmd/buildcache.py +++ b/lib/spack/spack/test/cmd/buildcache.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import errno import platform import pytest @@ -11,6 +12,7 @@ import spack.binary_distribution buildcache = spack.main.SpackCommand('buildcache') +install = spack.main.SpackCommand('install') @pytest.fixture() @@ -41,3 +43,16 @@ def test_buildcache_list_duplicates(mock_get_specs, capsys): output = buildcache('list', 'mpileaks', '@2.3') assert output.count('mpileaks') == 3 + + +def test_buildcache_create_fail_on_perm_denied( + install_mockery, mock_fetch, monkeypatch, tmpdir): + """Ensure that buildcache create fails on permission denied error.""" + install('trivial-install-test-package') + + tmpdir.chmod(0) + with pytest.raises(OSError) as error: + buildcache('create', '-d', str(tmpdir), + '--unsigned', 'trivial-install-test-package') + assert error.value.errno == errno.EACCES + tmpdir.chmod(0o700) diff --git a/lib/spack/spack/util/web.py b/lib/spack/spack/util/web.py index 4fb8c5a5911fbc9855e7bfcefd4b16d72ff066f3..8039dc5fdaf4212e39203fa7b1249b0fd2ad8bf6 100644 --- a/lib/spack/spack/util/web.py +++ b/lib/spack/spack/util/web.py @@ -205,6 +205,8 @@ def push_to_url( # needs to be done in separate steps. shutil.copy2(local_file_path, remote_file_path) os.remove(local_file_path) + else: + raise elif remote_url.scheme == 's3': if extra_args is None: