dotnet / interactive

.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
MIT License
2.84k stars 380 forks source link

System.Management.Automation not found #1790

Open Yucked opened 2 years ago

Yucked commented 2 years ago

Describe the bug

Setting up a docker container from scratch using alpine image. Everything builds as shown in the screenshot but whenever I create a new C#/PS notebook, it begins throwing exceptions and whatever is entered in the notebook and ran hangs forever.

File name: 'System.Management.Automation, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at Microsoft.DotNet.Interactive.PowerShell.PowerShellKernel..ctor()
   at Microsoft.DotNet.Interactive.App.CommandLine.CommandLineParser.CreateKernel(String defaultKernelName, FrontendEnvironment frontendEnvironment, StartupOptions startupOptions) in D:\a\_work\1\s\src\dotnet-interactive\CommandLine\CommandLineParser.cs:line 588
   at Microsoft.DotNet.Interactive.App.CommandLine.CommandLineParser.<>c__DisplayClass5_0.<<Create>g__JupyterHandler|11>d.MoveNext() in D:\a\_work\1\s\src\dotnet-interactive\CommandLine\CommandLineParser.cs:line 272
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.CommandHandler.GetExitCodeAsync(Object value, InvocationContext context)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.DotNet.Interactive.App.CommandLine.CommandLineParser.<>c__DisplayClass5_0.<<Create>b__3>d.MoveNext() in D:\a\_work\1\s\src\dotnet-interactive\CommandLine\CommandLineParser.cs:line 218
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass27_0.<<UseVersionOption>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__24_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<<UseDebugDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseExceptionHandler>b__0>d.MoveNext()
[I 2021-11-24 22:54:42.749 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), new random ports

Unhandled exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Management.Automation, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

.NET 6 SDK and Runtime is installed. PWSH 7.2.0 is also installed. Both are in path as well.

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ): The preview version (1.0.257301) since the one on nuget requires .net 5.

RUN dotnet tool install -g --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" Microsoft.dotnet-interactive && \
    dotnet interactive jupyter install && \
    mkdir ${NOTEBOOKS_DIR} && \
    ln -s ${PS_LOC}/pwsh /usr/bin/pwsh && \
    ln -s ${DOTNET_ROOT}/dotnet /usr/bin/dotnet

Screenshots

If applicable, add screenshots to help explain your problem. image image image

m0rphed commented 2 years ago

Have the same issue on arch linux with .NET 6 (6.0.100) and aspnet-runtime 6.0.0 'microsoft.dotnet-interactive' (version '1.0.257301')

Hairo commented 2 years ago

Same issue for me in EndeavourOS, tried installing powershell (because apparently System.Management.Automation is part of it) and still didn't work.

ssteck commented 2 years ago

I am also seeing this issue in AlamaLinux 8 with dotnet-interactive version 1.0.260601+9d1ecd3c06ba93e59bfef3842d2660c08d9e2ce5. I have ensured that powershell 7.2.0 is installed and launches successfully. I am seeing this error both when trying to use botnet-interactive with a jupyter notebook as well as just launching dotnet-interactive stdio

One thing I noticed is that the error being thrown is for System.Management.Automation, Version=7.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 while the only available 7.2.0 PowerShell package from the Microsoft repository includes System.Management.Automation, Version=7.2.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35 I don't know if it is possible to get the 7.2.0.0 DLL from somewhere or if that might be the issue.

maurictg commented 2 years ago

Same problem on Arch Are there any updates on this?

tulx17 commented 2 years ago

For Arch user, use the sdk build from AUR, it's newer than the community version. I don't know why but this do the trick.

rayhernandez commented 1 year ago

I had the same error:

Failed to start the Kernel.

Unhandled exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Management.Automation, Version=7.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

File name: 'System.Management.Automation, Version=7.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

Thanks for the tip @tunbk1002. I was finally able to fix this on Manjaro. I downloaded these from the AUR:

aur/dotnet-host-bin                 6.0.3.sdk201-1         6.0.4.sdk202-1
aur/dotnet-runtime-bin              6.0.3.sdk201-1         6.0.4.sdk202-1
aur/netstandard-targeting-pack-bin  6.0.3.sdk201-1         6.0.4.sdk202-1
aur/dotnet-targeting-pack-bin       6.0.3.sdk201-1         6.0.4.sdk202-1
aur/dotnet-sdk-bin                  6.0.3.sdk201-1         6.0.4.sdk202-1 
obratim commented 3 weeks ago

It is an issue in Microsoft.PowerShell.SDK package.

System.Management.Automation is stored in same git repository and is referenced as project, not as a package. As the result in the nuspec file written that it depends on a one version of System.Management.Automation, but inside nupkg archive under ref/net8.0/ there is another version of System.Management.Automation.dll.

This confusion causes error.

Reported a bug: https://github.com/PowerShell/PowerShell/issues/24110