Skip to content

Do not initialize config on spack compiler list#28042

Merged
tgamblin merged 6 commits intospack:developfrom
haampie:fix/dont-init-config-on-spack-compiler-list
Jan 12, 2022
Merged

Do not initialize config on spack compiler list#28042
tgamblin merged 6 commits intospack:developfrom
haampie:fix/dont-init-config-on-spack-compiler-list

Conversation

@haampie
Copy link
Copy Markdown
Member

@haampie haampie commented Dec 16, 2021

spack compiler list should show the current config and not write new compilers to config.

@haampie haampie linked an issue Dec 16, 2021 that may be closed by this pull request
@msimberg
Copy link
Copy Markdown
Contributor

Thanks @haampie! I don't know if this already fixes the following, but I noticed that doing spack spec <spec> also populates the list of compilers if empty.

@alalazo
Copy link
Copy Markdown
Member

alalazo commented Dec 16, 2021

@msimberg I personally agree with spack compiler list, but I think going further than that requires some more discussion. Reasons for that:

  1. We have been advertizing this behavior in the docs since ever so I think there might be people depending on it (" Spack searches for compilers on your machine automatically the first time it is run")
  2. There are other places where we automate configuration setting, if none is present, and I think we should be consistent. I would found it really strange if Spack looks automatically for e.g. core compilers for Lmod configuration but doesn't look for compilers on the platform

@msimberg
Copy link
Copy Markdown
Contributor

@msimberg I personally agree with spack compiler list, but I think going further than that requires some more discussion. Reasons for that:

1. We have been advertizing this behavior [in the docs](https://spack.readthedocs.io/en/latest/getting_started.html#compiler-configuration) since ever so I think there might be people depending on it (" Spack searches for compilers on your machine automatically the first time it is run")

2. There are other places where we automate configuration setting, if none is present, and I think we should be consistent. I would found it really strange if Spack looks automatically for e.g. core compilers for Lmod configuration but doesn't look for compilers on the platform

Thanks @alalazo for giving a bit of context. I wanted to open #28038 since I really wasn't sure if it was intended behaviour or not. It was surprising behaviour to me, since it definitely was not "the first time" I ran spack. The context was that I was planning to change to a new system-provided config file, and first wanted to check that I didn't have any leftover compilers defined elsewhere before I changed to the new config.

Arguably "the first time it is run" can have quite a few different definitions and does not need to be equivalent to "running spack compiler list if there are no configured compilers".

I'm obviously personally happy with this PR, but I don't have any demands that this is the right fix and lack the bigger picture.

Copy link
Copy Markdown
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good idea -- for 0.18.0 (though we'll hopefully be adding compilers as dependencies for that so this might change quite a bit before the release).

The docs don't actually seem to have anything that says spack compiler list should find compilers -- I grepped around and couldn't find it. They do have some sort of ambiguous mentions of spack compilers in configuration.rst and getting_started.rst.

Two requests:

  1. Update configuration.rst and getting_started.rst.
  2. If spack compiler list/spack compilers finds no compilers, it should prompt the user to run spack compiler find (if it's run from a tty). Can you add that?

@tgamblin tgamblin self-assigned this Dec 19, 2021
@haampie haampie force-pushed the fix/dont-init-config-on-spack-compiler-list branch from ecf58cf to 4ba8e32 Compare December 20, 2021 08:45
@spackbot-app spackbot-app bot added the documentation Improvements or additions to documentation label Dec 20, 2021
@haampie
Copy link
Copy Markdown
Member Author

haampie commented Dec 20, 2021

With the last commits:

$ SPACK_USER_CONFIG_PATH=$(mktemp -d) spack compiler list
==> No compilers available. Search for compilers? [y/n] n
$ SPACK_USER_CONFIG_PATH=$(mktemp -d) spack compiler list
==> No compilers available. Search for compilers? [y/n] y
==> Available compilers
-- clang ubuntu20.04-x86_64 -------------------------------------
[email protected]  [email protected]  [email protected]  [email protected]  [email protected]

-- gcc ubuntu20.04-x86_64 ---------------------------------------
[email protected]  [email protected]  [email protected]  [email protected]
$ SPACK_USER_CONFIG_PATH=$(mktemp -d) ~/spack/bin/spack compiler list | tee x
==> No compilers available. Search for compilers? [y/n] y
==> Available compilers
-- clang ubuntu20.04-x86_64 -------------------------------------
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

-- gcc ubuntu20.04-x86_64 ---------------------------------------
[email protected]
[email protected]
[email protected]
[email protected]
$ echo "hello world" | env SPACK_USER_CONFIG_PATH=$(mktemp -d) spack compiler list
==> No compilers available
$ SPACK_USER_CONFIG_PATH=$(mktemp -d) spack compiler list --scope=system
==> No compilers available

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Dec 20, 2021

@tgamblin I'm not sure what docs sections you were referring to in configuration.rst

@haampie
Copy link
Copy Markdown
Member Author

haampie commented Jan 3, 2022

bump @tgamblin

1 similar comment
@haampie
Copy link
Copy Markdown
Member Author

haampie commented Jan 12, 2022

bump @tgamblin

@spackbot-app spackbot-app bot added the tests General test capability(ies) label Jan 12, 2022
When `spack compiler list` is run without being restricted to a
particular scope, and no compilers are found, prompt to search for
compilers.
@haampie haampie force-pushed the fix/dont-init-config-on-spack-compiler-list branch from 289568e to 1d7356d Compare January 12, 2022 13:40
@haampie
Copy link
Copy Markdown
Member Author

haampie commented Jan 12, 2022

Okay, the interactive prompt is gone again, it's just showing nothing now when stdout is not a tty:

$ SPACK_USER_CONFIG_PATH=$PWD spack compiler list 
==> No compilers available. Run `spack compiler find` to autodetect compilers
$ SPACK_USER_CONFIG_PATH=$PWD spack compiler list --scope=system
==> No compilers available
$ SPACK_USER_CONFIG_PATH=$PWD spack compiler list | tee
$ echo $?
0

and there's a test that otherwise fails on develop.

@haampie haampie force-pushed the fix/dont-init-config-on-spack-compiler-list branch from 1d7356d to cea654b Compare January 12, 2022 13:46
@tgamblin tgamblin enabled auto-merge (squash) January 12, 2022 14:14
@tgamblin tgamblin merged commit d74396a into spack:develop Jan 12, 2022
pbrady pushed a commit to pbrady/spack that referenced this pull request Jan 12, 2022
When `spack compiler list` is run without being restricted to a
particular scope, and no compilers are found, say that none are 
available, and hint that the use should run spack compiler find to 
auto detect compilers.

* Improve docs
* Check if stdin is a tty
* add a test
@haampie haampie deleted the fix/dont-init-config-on-spack-compiler-list branch January 13, 2022 10:59
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Feb 1, 2022
When `spack compiler list` is run without being restricted to a
particular scope, and no compilers are found, say that none are 
available, and hint that the use should run spack compiler find to 
auto detect compilers.

* Improve docs
* Check if stdin is a tty
* add a test
EthanS94 pushed a commit to EthanS94/spack that referenced this pull request Feb 17, 2022
When `spack compiler list` is run without being restricted to a
particular scope, and no compilers are found, say that none are 
available, and hint that the use should run spack compiler find to 
auto detect compilers.

* Improve docs
* Check if stdin is a tty
* add a test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands compilers documentation Improvements or additions to documentation tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spack compiler list also finds compilers

4 participants