config edit: allow editing malformed spack.yaml file#51088
Merged
Conversation
Signed-off-by: Gregory Becker <[email protected]>
alalazo
requested changes
Aug 6, 2025
alalazo
reviewed
Aug 6, 2025
Signed-off-by: Gregory Becker <[email protected]>
Member
Author
|
@alalazo I had not realized we raise different error messages for yaml format errors and schema validation errors (even more fun, we call the latter I think this should be ready now. It looks like other spots that are trying to catch all environment yaml errors catch the same two errors I'm now catching for this. |
Signed-off-by: Gregory Becker <[email protected]>
alalazo
reviewed
Aug 12, 2025
Member
alalazo
left a comment
There was a problem hiding this comment.
Confirmed the PR is now working on the previous use case. Can we add a test in shell-tests that checks something similar to:
$ EDITOR=cat spack config edit
==> Error: Invalid environment configuration detected: error parsing YAML: near /tmp/spack-mou8_0x6/spack.yaml, 6, 9: expected ',' or ']', but got ':'
# This is a Spack Environment file.
#
# It describes a set of packages to be installed, along with
# configuration settings.
spack:
# add package specs to the `specs` list
specs: [
view: true
concretizer:
unify: true
$ echo $?
0?
Signed-off-by: Gregory Becker <[email protected]>
alalazo
approved these changes
Aug 18, 2025
alalazo
pushed a commit
that referenced
this pull request
Aug 22, 2025
Signed-off-by: Gregory Becker <[email protected]>
alalazo
pushed a commit
that referenced
this pull request
Aug 22, 2025
Signed-off-by: Gregory Becker <[email protected]>
alalazo
pushed a commit
that referenced
this pull request
Aug 22, 2025
Signed-off-by: Gregory Becker <[email protected]> Signed-off-by: Massimiliano Culpo <[email protected]>
haampie
pushed a commit
that referenced
this pull request
Sep 12, 2025
Signed-off-by: Gregory Becker <[email protected]> Signed-off-by: Massimiliano Culpo <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #41470 (
spack config editfails if thespack.yamlfile is malformed).When spack.yaml generates a ConfigFormatError and the command is
spack config edit, we cache that error asspack.environment.environment._active_environment_error.In
spack config edit, raise if there is an active environment error and the command would not edit thespack.yamlfile. If it is editing thespack.yamlfile, get the filename from the cached error since there is no properly active environment.