Skip to content

Allow enabling experimental features via env var #19256

Closed

Description

@SteveL-MSFT

Summary of the new feature / enhancement

In CI, if someone wants to use an experimental feature, it currently is inconvenient to write to the powershell.config.json file before pwsh starts and then potentially set it back if the container instance is being reused. Instead, it would be convenient to have pwsh also read from a env var like POWERSHELL_EXPERIMENTAL_FEATURES which is a comma separated list of the names of experimental features to enable.

The env var would override powershell.config.json for experimental features.

Proposed technical implementation details (optional)

No response

Activity

  1. added
    Issue-Enhancementthe issue is more of a feature request than a bug
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    WG-Enginecore PowerShell engine, interpreter, and runtime
    on Mar 1, 2023
  2. iSazonov commented on Mar 2, 2023

    @iSazonov
    Collaborator

    Maybe enhance Get-ExperimentalFeature cmdlet to generate the string for follow copy-paster.

  3. kilasuit commented on Mar 5, 2023

    @kilasuit
    Collaborator

    I don't see a problem with this, even though I don't like env vars and would rather not see more of them, I can see why implementing this would make a lot of sense in some cases

  4. iSazonov commented on Mar 5, 2023

    @iSazonov
    Collaborator

    Given the narrow purpose of this variable, I would suggest that it should be "hidden" with "__" prefix.


    Once upon a time we breathed a sigh of relief when Registry appeared in Windows and replaced a huge number of configuration files and environment variables. The positive effect was terrific.
    It's amazing to see that it's not being ported and there's not even a sign of it. :-(

  5. krokofant commented on Mar 6, 2023

    @krokofant

    Is there any chance that this could make it to a release of PowerShell 7.2? I'm very curious about how an upgrade path will be laid out so that PowerShell won't break CI system when the PSNativeCommandArgumentPassing feature is enabled by default on CI systems like Github actions.

    Being able to enable this feature on 7.2 via environment variable would make it easier to piece by piece migrate scripts to this feature...

  6. SteveL-MSFT commented on Mar 6, 2023

    @SteveL-MSFT
    MemberAuthor

    Emil Sundin (@krokofant) that's a good use case and something that could be considered since it's opt-in

  7. daxian-dbw commented on Mar 6, 2023

    @daxian-dbw
    Member

    In CI, if someone wants to use an experimental feature, it currently is inconvenient to write to the powershell.config.json file before pwsh starts and then potentially set it back if the container instance is being reused.

    Can you please provide an example to show how inconvenient it is today?

    Take Az Pipeline as an example, every -pwsh: | step runs in a new pwsh process, so you can set experimental features at the first -pwsh: | step, then the -pwsh: | steps after that will run in the pwsh processes with that experimental feature enabled. In the end, the last pwsh: | step can restore the experimental features, so the build agent will still have the original experimental feature settings.

    This doesn't seem very cumbersome to me ...

  8. SteveL-MSFT commented on Mar 7, 2023

    @SteveL-MSFT
    MemberAuthor

    Dongbo Wang (@daxian-dbw) container images get reused sometimes w/o resetting them, so you would need to backup the existing config, if the config is modified, you may want to retain those settings, so you would need to modify the config file rather than clobber it, then restore everything back. Certainly a worse case scenario, but this is exactly the scenario that was reported to me internally at Msft.

  9. JamesWTruher commented on Mar 8, 2023

    @JamesWTruher
    Collaborator

    the WG discussed this and weren't quite clear on the scenario, so a little elaboration would be helpful. We also suggested that a parameter to pwsh might be just as effective and reduce the expansion of the environment. There is also a concern about being able to remove the variable(s) from within PS (we think that the way dotnet removes environment variables is to just set them to an empty string, so clearing them from pwsh and then invokign might lead to ambiguity between no experimental features and use the standard config file.
    If an environment variable approach was accepted, we also suggested that we should follow the DOTNET_SettingNameHere for each experimental feature (rather than a list)

  10. added
    Waiting on AuthorThe PR was reviewed and requires changes or comments from the author before being accept
    and removed
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    on Mar 8, 2023
  11. SteveL-MSFT commented on Mar 13, 2023

    @SteveL-MSFT
    MemberAuthor

    A parameter on pwsh isn't as easily used in CI where pwsh is not called directly by the yaml. Within PS, you'd remove them as any env var by setting it to $null, so not sure how it's different here. Having individual env vars would be fine as well as long as experimental feature names don't allow for whitespace.

  12. ghost removed
    Waiting on AuthorThe PR was reviewed and requires changes or comments from the author before being accept
    on Mar 13, 2023
  13. krokofant commented on Jul 3, 2023

    @krokofant

    As november is slowly approaching and with it .NET 8 release and PowerShell 7.4 LTS, can this be prioritized?

    It would be very desirable to have an upgrade path before merging PowerShell 7.4 into Azure Pipelines/GitHub Action agents that has PSNativeCommandArgumentPassing enabled by default.

  14. SteveL-MSFT commented on Oct 9, 2023

    @SteveL-MSFT
    MemberAuthor

    Emil Sundin (@krokofant) unfortunately, 7.4 is on path for a release candidate, so we're not taking any more feature changes. This will show up in 7.5 at the earliest.

  15. added
    WG-ReviewedA Working Group has reviewed this and made a recommendation
    and removed
    WG-NeedsReviewNeeds a review by the labeled Working Group
    on Nov 27, 2023
  16. JamesWTruher commented on Nov 27, 2023

    @JamesWTruher
    Collaborator

    The @PowerShell/wg-powershell-engine discussed this again and before committing engineering effort on this, we would like to have a good discussion on how this should work take place, especially with regard to interaction of environment variables with settings found in the config.json file. It has been an issue for us in the past, so having a discussion before the engineering takes place of the behavior would be prudent.

  17. microsoft-github-policy-service commented on May 26, 2024

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.

    Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimeWG-ReviewedA Working Group has reviewed this and made a recommendation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions