-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module does not load on PowerShell Core/Linux #47
Comments
Hi, Will debug this today. Apologies for the late reply. |
So after a short test, here are my results: [gabriel@rossak ~ ]$ docker pull microsoft/powershell
Using default tag: latest
latest: Pulling from microsoft/powershell
898c46f3b1a1: Pull complete
63366dfa0a50: Pull complete
041d4cd74a92: Pull complete
6e1bee0f8701: Pull complete
87f96cbca9ae: Pull complete
01359b119872: Pull complete
Digest: sha256:65c203786b382796eeb66e6173964b6e2d830c9b6623823dacd40c7c9eb20622
Status: Downloaded newer image for microsoft/powershell:latest
[gabriel@rossak ~ ]$ docker image list
REPOSITORY TAG IMAGE ID CREATED SIZE
microsoft/powershell latest 6a978be224cc 6 days ago 373MB
[gabriel@rossak ~ ]$ docker run -it 6a978be224cc bash
root@06d8b067f1dc:/# pwsh
PowerShell 6.2.0
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/pscore6-docs
Type 'help' to get help.
PS /> install-module powershell-yaml -Force -Confirm:$false
PS /> import-module powershell-yaml
PS /> get-module powershell-yaml
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.4.0 powershell-yaml {ConvertFrom-Yaml, ConvertTo-Yaml, cfy, cty}
PS /> @{"hello"="world"} | cty
hello: world Do you have a sample dockerfile with which I could reproduce this? |
Aditional info: PS /> $PSVersionTable
Name Value
---- -----
PSVersion 6.2.0
PSEdition Core
GitCommitId 6.2.0
OS Linux 4.15.0-47-generic #50-Ubuntu SMP Wed Mar 13 10:44:52 UTC 2019
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0 PS /> [System.AppDomain]::CurrentDomain.GetAssemblies() | where-object Location -Match YamlDotNet.dll
GAC Version Location
--- ------- --------
False v4.0.30319 /root/.local/share/powershell/Modules/powershell-yaml/0.4.0/lib/netstandard1.3/YamlDotNet.dll PS /> [System.AppDomain]::CurrentDomain.GetAssemblies() | where-object Location -Match YamlDotNet.dll | fl *
DefinedTypes : {YamlDotNet.StandardRegexOptions, YamlDotNet.ReflectionExtensions, YamlDotNet.CultureInfoAdapter, YamlDotNet.PropertyInfoExtensions…}
ExportedTypes : {YamlDotNet.Serialization.BuilderSkeleton`1[TBuilder], YamlDotNet.Serialization.WrapperFactory`2[TComponentBase,TComponent],
YamlDotNet.Serialization.WrapperFactory`3[TArgument,TComponentBase,TComponent], YamlDotNet.Serialization.Deserializer…}
CodeBase : file:///root/.local/share/powershell/Modules/powershell-yaml/0.4.0/lib/netstandard1.3/YamlDotNet.dll
EntryPoint :
FullName : YamlDotNet, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null
ImageRuntimeVersion : v4.0.30319
IsDynamic : False
Location : /root/.local/share/powershell/Modules/powershell-yaml/0.4.0/lib/netstandard1.3/YamlDotNet.dll
ReflectionOnly : False
IsFullyTrusted : True
CustomAttributes : {[System.Runtime.CompilerServices.ExtensionAttribute()], [System.Runtime.CompilerServices.CompilationRelaxationsAttribute((Int32)8)],
[System.Runtime.CompilerServices.RuntimeCompatibilityAttribute(WrapNonExceptionThrows = True)],
[System.Diagnostics.DebuggableAttribute((System.Diagnostics.DebuggableAttribute+DebuggingModes)2)]…}
EscapedCodeBase : file:///root/.local/share/powershell/Modules/powershell-yaml/0.4.0/lib/netstandard1.3/YamlDotNet.dll
ManifestModule : YamlDotNet.dll
Modules : {YamlDotNet.dll}
GlobalAssemblyCache : False
HostContext : 0
SecurityRuleSet : None
|
I ran this on a linux machine. Installing docker for windows as well and giving this another try. |
Interesting. |
You may be using an older image. On the machine experiencing the issues, try to update the |
The above was indeed with a newer image, i.e. they have updated it in the last 11 days or so. If it is a .net core bug fix, then I hope that's made it as far as the Appveyor images! I'll re-enable loading of powershell-yaml in my PSCloudFormation repo and see if it builds now (locally first). |
Gets better! On my windows workstation, I'm getting the same with 0,4,0, but works in the latest powershell docker image. |
Interesting. Would you mind adding the following to your $PSVersionTable
$assemblies = [System.AppDomain]::CurrentDomain.GetAssemblies()
$yamlDotNet = $assemblies | where-object Location -Match YamlDotNet.dll
if ($yamlDotNet) {
$yamlDotNet | fl *
}
$assemblies I am curious if there is already a version of |
"Curiouser and curiouser" said Alice. Committed this fireflycons/PSCloudFormation@a2a43ee Now on the AppVeyor build, Windows is suddenly working, however Linux still fails. Worth noting that the Appveyor image is running PS 6.1.1 and the latest docker image is on 6.2.0 |
Just committed a change to appveyor.yml to see if I can force apt to upgrade powershell before it's used. |
You need to add: echo "msodbcsql msodbcsql/accept_eula select true" | sudo debconf-set-selections to your build script :). Such is life when we have to deal with non free software. |
To be honest, if the build server is an actual VM, and not a docker container, you could even do a: sudo snap install --classic powershell Then you can invoke the binary from /snap/bin/pwsh. This way you can skip the whole |
Had to leave that going earlier - kids to feed, put to bed etc! I believe Appveyor use VMs (cloud instances) rather than containers. If I try the snap route, I may also need to replace the existing pwsh binary with a link to the snap one as appveyor's build service is going to invoke the one it expects to be installed. |
Completely understand. I am on bottle duty currently. Does appveyor allow you to specify the interpretor path via a config option in the yaml? |
Got this far
Assuming that 1001 is the uid of the appveyor build service, and that I'm going to have to create and chown this directory after the snap install. Doesn't look like I can configure an alternative interpreter path. This is beginning to smell like an issue with the underlying .NET core framework that is no longer an issue in PS 6.2.0 which is targeting .netcore 2.1.8 |
hardcore. To be fair, you could probably get away with: mkdir -p /run/user/1001
chown 1001:1001 /run/user/1001 But at this point, I think it's easier to just run: echo "msodbcsql msodbcsql/accept_eula select true" | sudo debconf-set-selections before doing a: sudo apt-get update
sudo apt-get -q -y dist-upgrade |
To be extra paranoid, use: DEBIAN_FRONTEND=noninteractive apt-get -y -qq \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" dist-upgrade |
Found something.
|
That's nailed it. And it works on PS 6.1.1. CI now all green! |
Awesome! Great catch! :) Glad you managed to find this. This is why I asked you print the assemblies before importing I need to update Closing this issue for now. Feel free to open it again if you feel it should stay open. |
Try to determine if YamlDotNet is loaded, and check if it has required types. Throw an error if the loaded assemblies do not contain required types. This should at least offer more transparent error when loading powershell-yaml on a system that uses an incompatible YamlDotNet assembly. If no assembly is detected, load the bundled one. Fixes #46 Partially fixes #47
Changed If no assembly is present, we load the bundled one. |
Nice. Cheers |
Note that it does load on PSCore/Windows
Testing using docker image
microsoft/powershell
image in Docker for Windows withpowershell-yaml 0.4.0
..and a couple of hundred more lines, mostly complaining about the same missing reference.
Whether this is an issue with the
Add-Type
or is an underlying issue in the .net standard build ofYamlDotNet
, I don't know at this time.The text was updated successfully, but these errors were encountered: