Skip to content

Cannot write module files with path modifications containing the {} characters #29578

@jeanbez

Description

@jeanbez

Steps to reproduce

I’m struggling to set an environment variable in our setup_run_environment whose value must contain {}, e.g. this is the value my env variable should have when I load the package: async under_vol=0;under_info={}

def setup_run_environment(self, env):
    env.set('HDF5_PLUGIN_PATH', self.spec.prefix)
    vol_connector = 'async under_vol=0;under_info={}'
    env.set('HDF5_VOL_CONNECTOR', vol_connector)
    env.set('MPICH_MAX_THREAD_SAFETY', 'multiple')

Discussing with @tgamblin, we tried it with zlib, which works without an issue. But in my package I get:

==> hdf5-vol-async: Executing phase: 'cmake'
==> hdf5-vol-async: Executing phase: 'build'
==> hdf5-vol-async: Executing phase: 'install'
==> Error: SpecFormatStringError: Format string attributes must be non-empty

/Users/jlbez/Documents/repositories/spack/lib/spack/spack/build_environment.py:1065, in _setup_pkg_and_run:
       1062        tb_string = traceback.format_exc()
       1063
       1064        # build up some context from the offending package so we can
  >>   1065        # show that, too.
       1066        package_context = get_package_context(tb)
       1067
       1068        logfile = None

@tgamblin mentioned that since spack allows us to use, e.g., {name} and other spec format strings in variable names for module file templates, that is failing in module generation. As suggested, I'm also pinging @alalazo in this issue.

Error message

==> No patches needed for hdf5-vol-async
==> hdf5-vol-async: Executing phase: 'cmake'
==> hdf5-vol-async: Executing phase: 'build'
==> hdf5-vol-async: Executing phase: 'install'
==> [2022-03-17-18:04:50.690442] Error: SpecFormatStringError: Format string attributes must be non-empty

/Users/jlbez/Documents/repositories/spack/lib/spack/spack/build_environment.py:1065, in _setup_pkg_and_run:
       1062        tb_string = traceback.format_exc()
       1063
       1064        # build up some context from the offending package so we can
  >>   1065        # show that, too.
       1066        package_context = get_package_context(tb)
       1067
       1068        logfile = None

See build log for details:
  /var/folders/rk/35_wlhq12b35gv8ch8z58cqc0000gn/T/jlbez/spack-stage/spack-stage-hdf5-vol-async-1.0-jlbdspjkoslsyqbosrbolvqbwkde43fu/spack-build-out.txt

Traceback (most recent call last):
  File "/Users/jlbez/Documents/repositories/spack/lib/spack/spack/build_environment.py", line 1049, in _setup_pkg_and_run
    return_value = function(pkg, kwargs)
  File "/Users/jlbez/Documents/repositories/spack/lib/spack/spack/installer.py", line 2017, in build_process
    return installer.run()
  File "/Users/jlbez/Documents/repositories/spack/lib/spack/spack/installer.py", line 1879, in run
    spack.hooks.post_install(self.pkg.spec)
  File "/Users/jlbez/Documents/repositories/spack/lib/spack/spack/hooks/__init__.py", line 76, in __call__
    hook(*args, **kwargs)
  File "/Users/jlbez/Documents/repositories/spack/lib/spack/spack/hooks/module_file_generation.py", line 47, in post_install
    _for_each_enabled(spec, 'write')
  File "/Users/jlbez/Documents/repositories/spack/lib/spack/spack/hooks/module_file_generation.py", line 32, in _for_each_enabled
    getattr(generator, method_name)()
  File "/Users/jlbez/Documents/repositories/spack/lib/spack/spack/modules/common.py", line 886, in write
    context = self.context.to_dict()
  File "/Users/jlbez/Documents/repositories/spack/lib/spack/spack/tengine.py", line 65, in to_dict
    d = [(name, getattr(self, name)) for name in self.context_properties]
  File "/Users/jlbez/Documents/repositories/spack/lib/spack/spack/tengine.py", line 65, in <listcomp>
    d = [(name, getattr(self, name)) for name in self.context_properties]
  File "/Users/jlbez/Documents/repositories/spack/lib/spack/spack/modules/common.py", line 766, in environment_modifications
    x.value = spec.format(x.value)
  File "/Users/jlbez/Documents/repositories/spack/lib/spack/spack/spec.py", line 4197, in format
    write_attribute(self, attribute, color)
  File "/Users/jlbez/Documents/repositories/spack/lib/spack/spack/spec.py", line 4083, in write_attribute
    raise SpecFormatStringError(
spack.spec.SpecFormatStringError: Format string attributes must be non-empty
==> [2022-03-17-18:04:50.693633] Flagging hdf5-vol-async-1.0-jlbdspjkoslsyqbosrbolvqbwkde43fu as failed: SpecFormatStringError: Format string attributes must be non-empty
==> [2022-03-17-18:04:50.709935] ChildError: SpecFormatStringError: Format string attributes must be non-empty

Information on your system

I tried it on MacOS:

* **Spack:** 0.17.1-1610-0ce8b9d398
* **Python:** 3.9.10
* **Platform:** darwin-monterey-cannonlake
* **Concretizer:** clingo

I also tried it on Ubuntu:

* **Spack:** 0.17.1-1610-0ce8b9d398
* **Python:** 3.8.10
* **Platform:** linux-ubuntu20.04-sandybridge
* **Concretizer:** clingo

General information

  • I have run spack debug report and reported the version of Spack/Python/Platform
  • I have searched the issues of this repo and believe this is not a duplicate
  • I have run the failing commands in debug mode and reported the output

Metadata

Metadata

Labels

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions