[alpine Linux] - some missing standard Modules in alpine linux APK package · Issue #20143 · PowerShell/PowerShell · GitHub
Skip to content

[alpine Linux] - some missing standard Modules in alpine linux APK package #20143

Open

Description

Prerequisites

Steps to reproduce

  1. Use a alpine linux docker container
  2. install powershell (apk add powershell)
  3. try to install or import literally anything
  4. run in the error

Expected behavior

I assumed it at least is able to install and handle modules on linux already

Actual behavior

It triggers this error:


The term 'Install-Module' is not recognized as a name of a cmdlet,
function, script file, or executable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try
again.

Error details

No response

Environment data

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.6
PSEdition                      Core
GitCommitId                    7.3.6
OS                             Linux 6.4.0-3-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.4.11-1 (2023-08-17)
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
$env:PATH
/usr/lib/powershell:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Visuals

No response

Activity

  1. ThomasNieto commented on Aug 20, 2023

    @ThomasNieto
    Contributor

    If you run Get-Module -ListAvailable does the PowerShellGet module show up?

  2. 237dmitry commented on Aug 20, 2023

    @237dmitry

    What would if you install not in docker?

  3. the-hotmann commented on Aug 20, 2023

    @the-hotmann
    Author

    Hi and thanks for your quick answer,

    If you run Get-Module -ListAvailable does the PowerShellGet module show up?

    image

    Nope, so impossible to install anything with how it ships on alpine

    What would if you install not in docker?

    I don't have any native VM with alpine linux, but should not make any differrence, since:

    When I download the apk manually from here https://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/powershell-7.3.6-r0.apk and unzip with '7zip' I can see that in the folder
    'powershell-7.3.6-r0\usr\lib\powershell\Modules' it is already missing the modules - so
    it can not be there. There must have been some error when compiling/building the alpine apk:
    image

    So this version of the alpine installation package ships without important Modules, whether in docker or not.
    if the package does not bring it, it must be missing.

    Thank you in advance!

    P.S.: since I am already here:

    is there a way to also support this package for these architectures aswell?

    • x86/i386
    • ARMHF
    • PPC64LE
    • S390X
    • RISCV64
  4. jhoneill commented on Aug 20, 2023

    @jhoneill

    Martin Hotmann (@the-hotmann) I think it might be good to edit the title of this - based on your unzip this looks like a problem with the build process for one or more linux packages - the install-module error is one of many possible symptoms, but not the actual problem, and docker is not part of the issue either :-)

  5. changed the title [-][Linux] - The term 'Install-Module' is not recognized as a name of a cmdlet[/-] [+][alpine Linux] - The term 'Install-Module' is not recognized as a name of a cmdlet[/+] on Aug 20, 2023
  6. changed the title [-][alpine Linux] - The term 'Install-Module' is not recognized as a name of a cmdlet[/-] [+][alpine Linux] - some missing standard Modules in alpine linux APK package[/+] on Aug 20, 2023
  7. ThomasNieto commented on Aug 20, 2023

    @ThomasNieto
    Contributor

    According to the official install instructions the download is on the Releases page with an alpine tar.gz file. I validated that file has the correct built-in modules. Maybe someone else published it to the alpine package manager.

    Travis Plunk (@TravisEz13) does PowerShell release pipeline publish to alpine package manager?

  8. the-hotmann commented on Aug 20, 2023

    @the-hotmann
    Author

    According to the official install instructions the download is on the Releases page with an alpine tar.gz file. I validated that file has the correct built-in modules. Maybe someone else published it to the alpine package manager.

    That is litterally what I wrote in my last post here :)

    Travis Plunk (@TravisEz13) does PowerShell release pipeline publish to alpine package manager?

    I don't think so.
    According to the alpine package site https://pkgs.alpinelinux.org/package/edge/community/x86_64/powershell the maintainer is Antoine Martin (ayakael) which I already contacted by email to inform about that discrepancy. I linked this issue in the email.

    Since there is no GitHub repo or any other repo I have access to, where I could open the issue, I decided to open one here and send it to the maintainer, so he can follow up.

    Antoine Martin (@ayakael) answered my email and informed me about that he will look into the issue the next days.

  9. ayakael commented on Aug 21, 2023

    @ayakael

    Martin Hotmann (@the-hotmann) Thank you for opening this issue. I am the package maintainer for powershell (and dotnet) for Alpine Linux. Indeed, I can confirm the missing modules. I'm investigating how to get them included in the package, and I can't find an obvious way of building them from source. Arch Linux addressed this by copying the prebuilt modules from the upstream PowerShell package . Ideally, we should build these from source, this is not something that is allowed on Alpine Linux as we build everything from source. The psm1 script also installs the prebuilt modules from upstream.

    Any pointers would be appreciated.

  10. ayakael commented on Aug 21, 2023

    @ayakael

    I did a summary investigation of what it would entail to build these modules from source:

    • Most do not have buid-from-source instructions (only oneget and psreadline has instructions)
    • When they do, it involves building with a psm1 script. We have a bootstrap problem when wanting to build these before pwsh is available.
    • Releases aren't properly tagged (oneget and threadjob)
    • There is a warning that releases might not be available on Github in the future (PSReadLine)

    This doesn't bode well from a maintainer perspective, I'm afraid.

  11. the-hotmann commented on Aug 21, 2023

    @the-hotmann
    Author

    True that - just checked, the source does not have these Modules.
    But when I check the release page of v7.3.6: LINK
    I see that there is an alpine-package: https://github.com/PowerShell/PowerShell/releases/download/v7.3.6/powershell-7.3.6-linux-alpine-x64.tar.gz

    This does have the Modules included. I don't know who built that, but it is a tar.gz (like most .apk-files). But again just for x86_x64.
    So the questions would be: who built that (maybe Travis Plunk (@TravisEz13) as mentioned above?) and is there any info out there on how to properly build it?
    Let's wait and see if anyone does have an idea.

    In general I think it should be in the interest of Powershell to be built and supported for as many OS and Arches as possible.

  12. ayakael commented on Aug 21, 2023

    @ayakael

    True that - just checked, the source does not have these Modules. But when I check the release page of v7.3.6: LINK I see that there is an alpine-package: https://github.com/PowerShell/PowerShell/releases/download/v7.3.6/powershell-7.3.6-linux-alpine-x64.tar.gz

    This does have the Modules included. I don't know who built that, but it is a tar.gz (like most .apk-files). But again just for x86_x64. So the questions would be: who built that (maybe Travis Plunk (@TravisEz13) as mentioned above?) and is there any info out there on how to properly build it? Let's wait and see if anyone does have an idea.

    In general I think it should be in the interest of Powershell to be built and supported for as many OS and Arches as possible.

    That tar is likely produced with PowerShell's own build infrastructure, likely leveraging a a prebuilt binary of pwsh that runs a psm1 script in the source. Surmising from that script, those modules aren't actually built, but rather fetched and packaged as is in the tar.gz file. While this approach is acceptable on the .NET ecosystem, it is generally not acceptable on linux ecosystems.

    The powershell package available on Alpine's repo is the product of my porting the psm1 script into an APKBUILD (quite similar to a standard shell script), which Alpine's build infrastructure uses to produce an apk.

  13. 237dmitry commented on Aug 21, 2023

    @237dmitry

    I am sorry for offtop, can be used alpine tar.gz for musl void linux?

  14. ayakael commented on Aug 21, 2023

    @ayakael

    I am sorry for offtop, can be used alpine tar.gz for musl void linux?

    I encourage you to try, and see. Normally, portable packages targetting Alpine Linux actually targets linux-musl-x64 which is also Void Linux

  15. 10 remaining items

  16. kilasuit commented on Nov 30, 2023

    @kilasuit
    Collaborator

    Rich Lander (@richlander) to not make this topic stall I hope this screenshot helps you:

    Left: Official + Prebuilds Right: Alpine sourcebuild

    image
    Official + Prebuilds Alpine Sourcebuild Source needed?
    Microsoft.PowerShell.Archive ✓
    Microsoft.PowerShell.Host Microsoft.PowerShell.Host ✗
    Microsoft.PowerShell.Management Microsoft.PowerShell.Management ✗
    Microsoft.PowerShell.Security Microsoft.PowerShell.Security ✗
    Microsoft.PowerShell.Utility Microsoft.PowerShell.Utility ✗
    PackageManagement ✓
    PowerShellGet ✓
    PSReadLine ✓
    ThreadJob ✓

    Here again in a list, all modules which can not be build by source:

    * `Microsoft.PowerShell.Archive`
    
    * `PackageManagement`
    
    * `PowerShellGet`
    
    * `PSReadLine`
    
    * `ThreadJob`
    

    Thanks for helping!

    Antoine Martin (@ayakael) Martin Hotmann (@the-hotmann) - All those in that list marked as needed are already open sourced here on GitHub mostly under the PowerShell Organisation in their own Repos, other than PackageManagement which is under the Oneget repo. so should all be able to be built from their sources, if for any of those you find they can't be built from the source can you please raise an issue in their repo and link back to this issse for us please.

  17. the-hotmann commented on Dec 3, 2023

    @the-hotmann
    Author

    The goal is to allow people to use PSGallery.

    Sorry, but this is not 'the goal' at all. The goal is to provide a proper source-build PowerShell for alpine which provides the same OOB expirience as the official pwsh. This also is important so it can be maintained properly for all alpine architectures.
    Your goals may vary, but the goal of this issue/ticket/thread is not solely PS-Gallery.

    Rich Lander (@richlander) thank you very much for pointing that out.
    To make it a little more easy for Antoine Martin (@ayakael), here a list with the missing modules and the direct link to the repo

    Missing Package Directlink
    Microsoft.PowerShell.Archive https://github.com/PowerShell/Microsoft.PowerShell.Archive
    PackageManagement https://github.com/OneGet/oneget/
    PowerShellGet (v3) https://github.com/PowerShell/PowerShellGet
    PowerShellGetv2 (needed?) https://github.com/PowerShell/PowerShellGetv2
    PSReadLine https://github.com/PowerShell/PSReadLine
    ThreadJob https://github.com/PowerShell/ThreadJob

    Rich Lander (@richlander) there are indeed some more things that came to my attention. Some of the repos I found are not up-to-date and therefor I think a sourcebuild would not result in building the newest versions of each package.

    Let me provide a list with my findings:

    Package Github + Version PS-Gallery + Version OK?
    Microsoft.PowerShell.Archive LINK (1.1.0.0) PS-Gallery (1.2.5) ❌
    PackageManagement LINK (1.4) PS-Gallery (1.4.8.1) ❌
    PowerShellGet (v3) LINK (-) PS-Gallery (3.0.23-beta23) ❔
    PowerShellGetv2 (needed?) LINK (2.2.5.1) PS-Gallery (2.2.5) ✔️
    PSReadLine LINK (2.3.4) PS-Gallery (2.3.4) ✔️
    ThreadJob LINK (-) PS-Gallery (2.0.3) ❔

    Maybe the problem is with me not seeing the right thing?
    But I double-checked and it seems that some of the repositories of the packages are not up-to-date?
    Especially Microsoft.PowerShell.Archive and PackageManagement show a clear discrepancy, also in the date of the released tags, when you compare the newest releases to each other.

    Thanks in advance :)

  18. ayakael commented on Dec 3, 2023

    @ayakael

    Ryan Yates (@kilasuit)

    Echoeing Martin Hotmann (@the-hotmann), the situation hasn't changed as it relates to my observations done last august:

    * Most do not have buid-from-source instructions (only oneget and psreadline has instructions)
    * When they do, it involves building with a psm1 script. We have a bootstrap problem when wanting to build these before pwsh is available.
    * Releases aren't properly tagged (oneget and threadjob)
    * There is a warning that releases might not be available on Github in the future (PSReadLine)
    

    I'll open issues in the relevant repos to see what those teams can do to facilitate source-building.

  19. rhubarb-geek-nz commented on Dec 3, 2023

    @rhubarb-geek-nz

    Sorry, but this is not 'the goal' at all. The goal is to provide a proper source-build PowerShell for alpine which provides the same OOB expirience as the official pwsh.

    Is the intent for it to be packaged as a monolithic APK containing everything, or a set of smaller APKs so you can choose to have the core runtime of PowerShell and only add the modules that you want?

    I am thinking about the scenario of building an Alpine/PowerShell based Docker image where you don't need all the modules.

  20. ayakael commented on Dec 4, 2023

    @ayakael

    Sorry, but this is not 'the goal' at all. The goal is to provide a proper source-build PowerShell for alpine which provides the same OOB expirience as the official pwsh.

    Is the intent for it to be packaged as a monolithic APK containing everything, or a set of smaller APKs so you can choose to have the core runtime of PowerShell and only add the modules that you want?

    I am thinking about the scenario of building an Alpine/PowerShell based Docker image where you don't need all the modules.

    On my end, the intent is to provide a package that matches the feature of what is provided in the upstream tar. This means that if these modules are provided by Powershell/Powershell, they should be in the Alpine package.

  21. kilasuit commented on Dec 6, 2023

    @kilasuit
    Collaborator

    The goal is to allow people to use PSGallery.

    Sorry, but this is not 'the goal' at all.

    There are multiple goals in play here, and the use of the gallery/release package as opposed to requiring a clean build from source is the most efficient use of all the computational time, power and other resources so is the most environmentally friendly way forward for us due to reduced infrastructure & other associated costs that come with the build from source requirement, that said, we do also want to ensure that build from source is something that is not only possible, but easy to work with too, so we need to make things better here going forward,

    Most do not have buid-from-source instructions

    Not all software/module have or need a proper build process, so may be up with this is the source & it doesn't require to be "built" to be used, however this is something that should in future be much easier for those that do require to be built to be useable and is some tech debt that we do need to clean up on.

    We have a bootstrap problem when wanting to build these before pwsh is available

    This is a problem that I can't see a way forward from as we currently use a PowerShell module to help with the build process as all of the tooling that we use for building pwsh either already has the pwsh executable & other ones we rely on or can easily be bootstrapped with a pre-build step using an existing built version of those tools, which I don't see benefit in moving away from, and I don't think stops from building from source,

  22. the-hotmann commented on Mar 11, 2024

    @the-hotmann
    Author

    Am I reading right, that there is some work beeing done on this?

    #21316

    Just curious. Or is this just another open issue for the same problem?

  23. ayakael commented on Apr 13, 2024

    @ayakael

    Sorry for the lack of work on this. I do this on my off time and I've been busy with other projects. I'm hoping to work on this in May to get it in before the next Alpine Linux release. What needs to happen till then is that the libraries need to update their GitHub repo for me to be able to pull from them. I've opened the following issues to address this:

  24. ayakael commented on Apr 13, 2024

    @ayakael

    The approach I will take is create a package for each library that will be pulled automatically when installing powershell, so that I can work on low hanging fruits first and get them in incrementally.

  25. hpdsvg commented on Jun 26, 2024

    @hpdsvg

    I wanted to share a solution that worked for me while working on building an alpine 3.20 arm64 and amd64 container image with PowerShell 7.4. After encountering several challenges, I was able to successfully build the container using the following command in my Dockerfile:

    # https://github.com/dotnet/runtime/issues/103063#issuecomment-2150215510
    ENV DOTNET_EnableWriteXorExecute=0
    
    RUN apk add --update \
        curl unzip powershell \
        && pwsh -NoLogo -NoProfile -Command " \
        mkdir -p /root/.local/share/powershell/Modules ; \
        curl -L https://psg-prod-eastus.azureedge.net/packages/packagemanagement.1.4.8.1.nupkg -o /tmp/PackageManagement.nupkg ; \
        unzip -o /tmp/PackageManagement.nupkg -d /root/.local/share/powershell/Modules/PackageManagement ; \
        rm /tmp/PackageManagement.nupkg ; \
        curl -L https://psg-prod-eastus.azureedge.net/packages/powershellget.2.2.5.nupkg -o /tmp/PowerShellGet.nupkg ; \
        unzip -o /tmp/PowerShellGet.nupkg -d /root/.local/share/powershell/Modules/PowerShellGet ; \
        rm /tmp/PowerShellGet.nupkg ; \
        Import-Module /root/.local/share/powershell/Modules/PackageManagement ; \
        Import-Module /root/.local/share/powershell/Modules/PowerShellGet ; \
        "
    

    And then Install-Module was working like normal.
    I hope this solution helps others facing similar issues. It's been a journey figuring this out, and I'm glad to contribute back to the community with this finding. Thanks for all the above comments. It was very helpful!

  26. CrhistianH commented on Aug 14, 2024

    @CrhistianH

    I wanted to share a solution that worked for me while working on building an alpine 3.20 arm64 and amd64 container image with PowerShell 7.4. After encountering several challenges, I was able to successfully build the container using the following command in my Dockerfile:

    # https://github.com/dotnet/runtime/issues/103063#issuecomment-2150215510
    ENV DOTNET_EnableWriteXorExecute=0
    
    RUN apk add --update \
        curl unzip powershell \
        && pwsh -NoLogo -NoProfile -Command " \
        mkdir -p /root/.local/share/powershell/Modules ; \
        curl -L https://psg-prod-eastus.azureedge.net/packages/packagemanagement.1.4.8.1.nupkg -o /tmp/PackageManagement.nupkg ; \
        unzip -o /tmp/PackageManagement.nupkg -d /root/.local/share/powershell/Modules/PackageManagement ; \
        rm /tmp/PackageManagement.nupkg ; \
        curl -L https://psg-prod-eastus.azureedge.net/packages/powershellget.2.2.5.nupkg -o /tmp/PowerShellGet.nupkg ; \
        unzip -o /tmp/PowerShellGet.nupkg -d /root/.local/share/powershell/Modules/PowerShellGet ; \
        rm /tmp/PowerShellGet.nupkg ; \
        Import-Module /root/.local/share/powershell/Modules/PackageManagement ; \
        Import-Module /root/.local/share/powershell/Modules/PowerShellGet ; \
        "
    

    And then Install-Module was working like normal. I hope this solution helps others facing similar issues. It's been a journey figuring this out, and I'm glad to contribute back to the community with this finding. Thanks for all the above comments. It was very helpful!

    I was having exactly the same issue and you managed to solve it flawlessly.
    I'm just so glad I came up to find your comment. You could have just kept it to yourself. Thank you so much for sharing!

  27. ayakael commented on Oct 25, 2024

    @ayakael

    Hello all. I've pushed a change that mitigated this issue. The standard modules that are pulled by powershell's build process were copied to the Modules folder, thus they are now packaged in the Alpine Linux package starting with v7.4.6-r2 on edge and v7.4.6-r1 on 3.20. Apologies for the time it took to address this issue.

  28. ayakael commented on Jan 21, 2025

    @ayakael

    This should be closed.

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

    Needs-TriageThe issue is new and needs to be triaged by a work group.OS-Linux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions