Skip to content

Module manifest .psd1 file on linux/mac doesn't support ProcessorArchitecture='AMD64' or 'x86' #6533

Closed

Description

@abhisheksinha89

Steps to reproduce

On Linux/Mac:
Open any module .psd1 file and update/ add the following line:
ProcessorArchitecture = 'Amd64'
OR
ProcessorArchitecture ='x86'

Please note: ProcessorArchitecture='None' seems to work.

Expected behavior

The module should be discoverable using Get-Module -ListAvailable and Import-Module should work fine as it does on Windows.

Actual behavior

The module is not listed using Get-Module and Import-Module fails with this error:

Import-Module : Unable to load DLL 'api-ms-win-core-sysinfo-l1-1-0.dll': The specified module or one of its dependencies could not be found.
 (Exception from HRESULT: 0x8007007E)
At line:1 char:1
+ Import-Module Standard
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Import-Module], DllNotFoundException
+ FullyQualifiedErrorId : System.DllNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand

Environment data

> $PSVersionTable

Activity

  1. added
    WG-Engine
    on Mar 30, 2018
  2. added
    Issue-Bug
    on Apr 14, 2018
  3. DWSR commented on Dec 12, 2018

    @DWSR

    Just ran across this myself. Was going to file a separate issue, but will throw my comments in here instead. I'm not sure if this is specific to compiled modules or not, but that's how I came across mine.

    Steps to reproduce

    1. Create a cmdlet in C# targetting .NET Standard (I used 2.0, not sure the version matters) and compile it via dotnet publish --self-contained.
    2. Create a .psd1 manifest for that module
    3. Specify the output assembly file in NestedModules in the .psd1
    4. Specify a ProcessorArchitecture of Amd64 in the .psd1
    5. Attempt to import the module

    Expected behavior

    • The module is imported properly on non-Windows systems

    Actual behavior

    • On Windows systems, the module imports properly.
    • On non-Windows systems, the module import will fail with the following error:
    ipmo : Unable to load shared library 'api-ms-win-core-sysinfo-l1-1-0.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libapi-ms-win-core-sysinfo-l1-1-0.dll: cannot open shared object file: No such file or directory
    At line:1 char:16
    + cd /powerkube; ipmo ./output/PowerKube.psd1
    +                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], DllNotFoundException
    + FullyQualifiedErrorId : System.DllNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand
    

    Environment data

    Linux

    Name                           Value
    ----                           -----
    PSVersion                      6.1.1
    PSEdition                      Core
    GitCommitId                    6.1.1
    OS                             Linux 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018
    Platform                       Unix
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    WSManStackVersion              3.0
    

    Windows

    Name                           Value
    ----                           -----
    PSVersion                      6.1.1
    PSEdition                      Core
    GitCommitId                    6.1.1
    OS                             Microsoft Windows 10.0.17134
    Platform                       Win32NT
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    WSManStackVersion              3.0
    

    Stack Trace

    at System.Management.Automation.PsUtils.NativeMethods.GetSystemInfo(SYSTEM_INFO& lpSystemInfo)
       at System.Management.Automation.PsUtils.GetProcessorArchitecture(Boolean& isRunningOnArm)
       at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo manifestScriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions& options, Boolean& containedErrors)
       at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(ExternalScriptInfo scriptInfo, ManifestProcessingFlags manifestProcessingFlags, Version minimumVersion, Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions& options)
       at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(PSModuleInfo parentModule, String fileName, String moduleBase, String prefix, SessionState ss, Object privateData, ImportModuleOptions& options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound)
       at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(String fileName, String moduleBase, String prefix, SessionState ss, ImportModuleOptions& options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found)
       at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName(ImportModuleOptions importModuleOptions, String name)
       at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()
       at System.Management.Automation.Cmdlet.DoProcessRecord()
       at System.Management.Automation.CommandProcessor.ProcessRecord()
    
  4. added a commit that references this issue on Dec 13, 2018
  5. markekraus commented on Dec 16, 2018

    @markekraus
    Contributor

    I looked at this per Brandon McNama (@DWSR) request.

    Upon importing a module GetProcessorArchitechture() is called here

    ProcessorArchitecture currentArchitecture = PsUtils.GetProcessorArchitecture(out isRunningOnArm);

    which is defined here

    internal static ProcessorArchitecture GetProcessorArchitecture(out bool isRunningOnArm)

    Which then calls GetStsyemInfo which is defined here

    [DllImport(PinvokeDllNames.GetSystemInfoDllName)]
    internal static extern void GetSystemInfo(ref SYSTEM_INFO lpSystemInfo);

    which is PINvoking the api-ms-win-core-sysinfo-l1-1-0.dll as defined here:

    internal const string GetSystemInfoDllName = "api-ms-win-core-sysinfo-l1-1-0.dll"; /*45*/

    This is why on non-windows Unable to load shared library 'api-ms-win-core-sysinfo-l1-1-0.dll' happens

  6. ZonderP commented on Oct 22, 2019

    @ZonderP

    Will this be addressed for the final release of Powershell Core 7?
    It is still an issue in Preview 4.

  7. ZonderP commented on Jan 9, 2020

    @ZonderP

    Again:
    Will this be addressed for the final release of Powershell Core 7?
    It is still an issue in RC1.

  8. SteveL-MSFT commented on Jan 9, 2020

    @SteveL-MSFT
    Member

    I believe #11046 will resolve this

  9. iSazonov commented on Jan 14, 2020

    @iSazonov
    Collaborator

    I hope it was fixed in #11046 but we need to do manual check.

  10. ZonderP commented on Jan 17, 2020

    @ZonderP

    Thanks! Works now in Powershell 7 RC2!

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-BugResolution-FixedWG-Engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions