PowerShell / MMI

Other
24 stars 17 forks source link

Doesn't work for macOS #33

Closed TravisEz13 closed 4 years ago

TravisEz13 commented 6 years ago

https://github.com/PowerShell/PowerShell/issues/5970

Steps to reproduce

1. Install latest release of Powershell Core on Mac OS High Sierra
2. Build generic DSC config script
3. Error is immediately produced that DLL is unable to be loaded.

Expected behavior

DSC config is not marked as broken

Actual behavior

image


[PowerShell]
System.DllNotFoundException: Unable to load DLL 'libmi.so': The specified module or one of its dependencies could not be found.
 (Exception from HRESULT: 0x8007007E)
   at Microsoft.Management.Infrastructure.Native.NativeMethods.MI_Application_InitializeV1(UInt32 flags, String applicationID, IndirectPtr extendedError, DirectPtr application)
   at Microsoft.Management.Infrastructure.Native.MI_Application.Initialize(String applicationId, MI_Instance& extendedError, MI_Application& application)
   at Microsoft.Management.Infrastructure.Internal.CimApplication.GetApplicationHandle()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at Microsoft.Management.Infrastructure.Internal.CimApplication.get_Handle()
   at Microsoft.Management.Infrastructure.Serialization.CimMofDeserializer..ctor()
   at Microsoft.Management.Infrastructure.Serialization.CimMofDeserializer.Create()
   at Microsoft.PowerShell.DesiredStateConfiguration.CimDSCParser..ctor(OnClassNeeded onClassNeeded)
   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.ImportClasses(String path, Tuple`2 moduleInfo, Collection`1 errors)
   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.Initialize(Collection`1 errors, List`1 modulePathList)
   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.LoadDefaultCimKeywords(Dictionary`2 functionsToDefine, Collection`1 errors, List`1 modulePathList, Boolean cacheResourcesFromMultipleModuleVersions)
   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.LoadDefaultCimKeywords(Collection`1 errors)
   at System.Management.Automation.Language.Parser.ConfigurationStatementRule(IEnumerable`1 customAttributes, Token configurationToken)

Environment data

Name                           Value
----                           -----
PSVersion                      6.0.0
PSEdition                      Core
GitCommitId                    v6.0.0
OS                             Darwin 17.3.0 Darwin Kernel Version 17.3.0: Thu Nov  9 18:09:22 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

I also repro'ed on

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.4
PSEdition                      Core
GitCommitId                    6.1.0-preview.4
OS                             Darwin 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Although the error is slightly different in preview

System.DllNotFoundException: Unable to load shared library 'libmi.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(liblibmi.so, 1): image not found
   at Microsoft.Management.Infrastructure.Native.NativeMethods.MI_Application_InitializeV1(UInt32 flags, String applicationID, IndirectPtr extendedError, DirectPtr application)
   at Microsoft.Management.Infrastructure.Native.MI_Application.Initialize(String applicationId, MI_Instance& extendedError, MI_Application& application)
   at Microsoft.Management.Infrastructure.Internal.CimApplication.GetApplicationHandle()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location where exception was thrown ---
   at System.Lazy`1.CreateValue()
   at Microsoft.Management.Infrastructure.Internal.CimApplication.get_Handle()
   at Microsoft.Management.Infrastructure.Serialization.CimMofDeserializer..ctor()
   at Microsoft.Management.Infrastructure.Serialization.CimMofDeserializer.Create()
   at Microsoft.PowerShell.DesiredStateConfiguration.CimDSCParser..ctor(OnClassNeeded onClassNeeded)
   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.ImportClasses(String path, Tuple`2 moduleInfo, Collection`1 errors)
   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.Initialize(Collection`1 errors, List`1 modulePathList)
   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.LoadDefaultCimKeywords(Dictionary`2 functionsToDefine, Collection`1 errors, List`1 modulePathList, Boolean cacheResourcesFromMultipleModuleVersions)
   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache.LoadDefaultCimKeywords(Collection`1 errors)
   at System.Management.Automation.Language.Parser.ConfigurationStatementRule(IEnumerable`1 customAttributes, Token configurationToken)
samueljmello commented 5 years ago

Any word on this?

TravisEz13 commented 5 years ago

@PaulHigin

PaulHigin commented 5 years ago

I am currently working on higher priority work items. I should have time to look at this in early October.

TravisEz13 commented 5 years ago

Code is here: https://github.com/PowerShell/MMI/blob/b35df8fcf766127221aaa02c474540aa95249722/src/Microsoft.Management.Infrastructure/Native/MI_PlatformSpecific.cs

wannansible commented 5 years ago

Paul, were you able to find time to look into this?

BrianFarnhill commented 5 years ago

@PaulHigin Any updates here? I'm having the same issue at the moment

avishnyakov commented 5 years ago

Still exists with PowerShell 6.1.1.

TravisEz13 commented 5 years ago

We discussed this and we think we can fix this bug at the beginning of 6.3 preview releases.

PleaseStopAsking commented 4 years ago

@TravisEz13 Any chance this is being worked on yet?

TravisEz13 commented 4 years ago

@adityapatwardhan is working on this. Please note that there are also bug in libmi itself. the omi project has be declared obsolete as is not fixing these issues. I would recommend looking for another solution such a PowerShell remoting over SSH.

PleaseStopAsking commented 4 years ago

@adityapatwardhan is working on this. Please note that there are also bug in libmi itself. the omi project has be declared obsolete as is not fixing these issues. I would recommend looking for another solution such a PowerShell remoting over SSH.

Was unaware that OMI was going to be deprecated. With that said, how does PS remoting over SSH solve the issue of building/editing DSC configuration files locally on MacOS?

TravisEz13 commented 4 years ago

Sorry, it doesn’t. Let me talk to the DSC team and see what their plans our in this space.

TravisEz13 commented 4 years ago

@PleaseStopAsking DSC wasn’t aware of the deeper problem in OMI. @amitsara is supposed to investigate adding DSC compilation tests for macOS. I’m not sure the deeper issue would be hit in this code path. I’m sorry, I was thinking about PowerShell remoting over OMI.

PleaseStopAsking commented 4 years ago

@TravisEz13 Thanks for digging into this and bringing it to the DSC team to investigate. I will follow up with them to see where to track this at.

TravisEz13 commented 4 years ago

https://github.com/MicrosoftDocs/PowerShell-Docs/pull/5726