Local variables in easyconfig files

This page discusses the use of local variables in easyconfig files.

For more general information on writing easyconfig files, please see Writing easyconfig files: the basics.

Motivation & context

When composing easyconfig files, it can sometimes make sense to use one or more local variables to define easyconfig parameters in a cleaner way, for example to avoid copy-pasting values that are used multiple times, or to avoid too long lines (longer than the maximum width of 120 characters as specified in code style). A local variable within the context of easyconfig files is any variable that does not correspond to a known easyconfig parameter (either general of easyblock-specific).

One thing that is easily overlooked is the importance of how these local variables are named: you should try and avoid that the names of local variables will match with the name of an easyconfig parameter that may get introduced in future EasyBuild versions. If that would happen, the semantics of the easyconfig file will change which may either result in a broken installation or perhaps a different installation than was intended (which could be worse than a broken one).

Avoiding that names of local variables are close to the name of (future) easyconfig parameters is also important, because of the “typo detection” feature that EasyBuild has: if the name of a local variable is too close to a known easyconfig parameter, EasyBuild will assume you have made a mistake, and will report a typo error, for example:

ERROR: Failed to process easyconfig example.eb:
You may have some typos in your easyconfig file: configopt -> configopts

Changes in EasyBuild v4.0 w.r.t. local variables in easyconfig files

Some changes were made in EasyBuild v4.0 to discourage the use of poorly named local variables:

Specifying what should be done when non-confirming local variables are found via --local-var-naming-check

Using the --local-var-naming-check configuration option, you can specify what should be done when one or more local variables are found that do not follow the recommended naming scheme easyconfig_files_local_variables_naming_scheme:

  • --local-var-naming-check=error: fail with an error if any easyconfig file that was parsed includes local variables that do not follow the recommended naming scheme;
  • --local-var-naming-check=log: only log a warning (but do not print it) if any easyconfig file that was parsed includes local variables that do not follow the recommended naming scheme;
  • --local-var-naming-check=warn [default]: print a warning if any easyconfig file that was parsed includes local variables that do not follow the recommended naming scheme;

The default is set such that non-confirming local variables are only reported through a printed warning, but do not result in cancelling the installation (since they’re usually not actually problematic).