Skip to content

Feature Request: Import-Module validate compatible operating systems #9784

Closed

Description

Summary of the new feature/enhancement

There are cases when a module only works on a specific operating systems. Today module authors can tag a module in PSGallery stating which OS is supported. However, there is no enforcement from PowerShell itself to prevent a user from importing an incompatible module.

This request also goes along with #3751 to add support for #requires -OS.

PowerShell 7 would be the best time to release this functionality.

Proposed technical implementation details (optional)

Add CompatibleOS field in the PSD1 with valid values of Windows, MacOS, and Linux. Then Import-Module can be updated use that field to prevent importing an incompatible module.

Activity

  1. BrucePay commented on May 31, 2019

    @BrucePay
    Collaborator

    Hi @tnieto88, Do you think just specifying Window/Linux/Mac is enough or do you see a need for more detail? What about OS version? For example, the new Windows "terminal" requires the latest update (1903 IIRC.) And then there are all the different Linux distros. The tricky bit of course is getting that detailed information since "uname -a" doesn't return the distro name or version.

    (On a related note; on Windows there is already the CompatiblePSEditions field for Desktop and Core that is (now) enforced).

  2. ThomasNieto commented on May 31, 2019

    @ThomasNieto
    ContributorAuthor

    Hello Bruce Payette (@BrucePay), I think the current level of detail is fine. The values align with the automatic variables and with RFC#35. As for OS version I personally haven't had a need yet to specify a minimum version.

  3. kilasuit commented on Jun 2, 2019

    @kilasuit
    Collaborator

    This to me feels like there needs to be an addition to the properties available in the psd1 that accompanies a module that add's at least simple OS values. However this needs to be done with caution as it likely will break down compatibility again like CompatiblePSEditions did

  4. ThomasNieto commented on Jun 3, 2019

    @ThomasNieto
    ContributorAuthor

    I agree adding a new PSD1 field that prevents importing on earlier versions is not ideal and would hurt adoption. Since PowerShellGet is getting rewritten with PS7 I mentioned in PowerShell/PowerShell-RFC#185 that may be good to move the built-in module (*-Module) commands to PowerShellGet. This would allow older PS versions to make use of enhancements and import any new PSD1 fields.

    When this change is made, built-in *-Module commands should be updated to support semver as well as [System.Version] (for backwards compatibility). If the built-in commands are updated that brings up a question about how will older versions of PowerShell handle that. There are issues with the current paradigm of trying to force semver into a system that doesn't support it. We get issues like PowerShell/PowerShellGet#324 and PowerShell/PowerShellGet#204.

    What will be the minimum PS version supported for PowerShellGet v3? If it's less than PS 7 then it may be worth breaking out the built-in *-Module commands from PowerShell into PowerShellGet to add support for semver in older PS versions.

  5. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  6. microsoft-github-policy-service commented on Nov 16, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

  7. microsoft-github-policy-service commented on Nov 23, 2023

    @microsoft-github-policy-service
    Contributor

    This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-No ActivityIssue has had no activity for 6 months or more

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions