Skip to content
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

dotnet-sdk-6.0 version 6.0.301 on Ubuntu LTS 22.04 breaks the Q# Language Extension in Visual Studio Code #26065

Closed
Matthias-vdE opened this issue Jun 16, 2022 · 4 comments
Labels
Area-NetSDK untriaged Request triage from a team member

Comments

@Matthias-vdE
Copy link

Describe the bug

IntelliSense is no longer working on .qs files in Visual Studio Code version 1.68.1, running on Ubuntu LTS 22.04. For example, all open statements such as "open Microsoft.Quantum.Canon;" have a red squiggly line stating "No namespace with the name "Microsoft.Quantum.Canon" exists."

Version 6.0.301 of the dotnet SDK seemingly breaks the Intellisense portion of the extension "Microsoft Quantum Development Kit for Visual Studio Code v0.24.210930". The output of the Q# Language Extension produces the following:

[Info  - 9:43:54 PM] workspace folder: /home/test/Documents/test
[Error - 9:43:55 PM] MSBuild error in /usr/share/dotnet/sdk/6.0.301/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): The "ProcessFrameworkReferences" task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly 'NuGet.Frameworks, Version=6.2.1.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621)
File name: 'NuGet.Frameworks, Version=6.2.1.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
 ---> System.IO.FileLoadException: Could not load file or assembly 'NuGet.Frameworks, Version=6.2.1.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at Microsoft.Build.Shared.MSBuildLoadContext.Load(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at System.Linq.Enumerable.WhereEnumerableIterator`1.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Microsoft.NET.Build.Tasks.ProcessFrameworkReferences.ExecuteCore()
   at Microsoft.NET.Build.Tasks.TaskBase.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
[Error - 9:43:55 PM] Failed to restore project '/home/test/Documents/test/test.csproj'.
[Error - 9:43:55 PM] MSBuild error in /usr/share/dotnet/sdk/6.0.301/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): The "ProcessFrameworkReferences" task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly 'NuGet.Frameworks, Version=6.2.1.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621)
File name: 'NuGet.Frameworks, Version=6.2.1.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
 ---> System.IO.FileLoadException: Could not load file or assembly 'NuGet.Frameworks, Version=6.2.1.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at Microsoft.Build.Shared.MSBuildLoadContext.Load(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at System.Linq.Enumerable.WhereEnumerableIterator`1.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Microsoft.NET.Build.Tasks.ProcessFrameworkReferences.ExecuteCore()
   at Microsoft.NET.Build.Tasks.TaskBase.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
[Error - 9:43:55 PM] Failed to resolve assembly references for project '/home/test/Documents/test/test.csproj'.
Discovered Q# project '/home/test/Documents/test/test.csproj'.
Loading project '/home/test/Documents/test/test.csproj'.
Done loading project '/home/test/Documents/test/test.csproj'

This did not happen with version 6.0.106.

To Reproduce

Install the dotnet-sdk-6.0 version 6.0.301 on Ubuntu 22.04 LTS.
Install the latest version of VS Code with the QDK extension.
Open any .qs file and wait for the Q# Language Extension to load.

I can reproduce this issue following these steps on a completely fresh install of Ubuntu.

Exceptions (if any)

Further technical details

  • Include the output of dotnet --info:
NET SDK (reflecting any global.json):
 Version:   6.0.301
 Commit:    43f9b18481

Runtime Environment:
 OS Name:     pop
 OS Version:  22.04
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.301/

Host (useful for support):
  Version: 6.0.6
  Commit:  7cca709db2

.NET SDKs installed:
  6.0.301 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
Version: 1.68.1
Commit: 30d9c6cd9483b2cc586687151bcbcd635f373630
Date: 2022-06-15T02:58:26.441Z
Electron: 17.4.7
Chromium: 98.0.4758.141
Node.js: 16.13.0
V8: 9.8.177.13-electron.0
OS: Linux x64 5.17.5-76051705-generic
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Linux untriaged Request triage from a team member labels Jun 16, 2022
@Matthias-vdE Matthias-vdE changed the title dotnet-sdk-6.0 version 6.0.301 on UbuntU LTS 22.04 breaks the Q# Language Extension in Visual Studio Code dotnet-sdk-6.0 version 6.0.301 on Ubuntu LTS 22.04 breaks the Q# Language Extension in Visual Studio Code Jun 16, 2022
@Matthias-vdE
Copy link
Author

(Not sure whether this bug should be reported here, or over at the https://github.com/microsoft/qsharp-compiler repo)

@baronfel
Copy link
Member

This is a perfectly reasonable place for it, thank you for reporting. We'll triage and get back to you as soon as possible!

@baronfel
Copy link
Member

I did some digging and I think this does need to be moved to/reopened at the qsharp-compiler repo.

The root of the issue is that the Q# language services bundle a reference to NuGet that isn't compatible with the version of NuGet shipped in the 6.0.301 SDK (in this case it's lower than the SDK version). This is a common problem of tools that use libraries that overlap with the libraries bundled in the SDK. In order to fix this, the Q# language services should:

  • mark the NuGet.Frameworks dependency with ExcludeAssets="runtime" so that the dll is not included in the bundled package.
    • this should make it so the Q# compiler inherits the version of NuGet being used by the SDK (which is also in line with use of the SDK's MSBuild).
    • this is also inline with the declarations of the MSBuild libraries in the Q# project

In the meantime, users should be able to delete the nuget dll from the extension's language server download location. This differs by OS, but on Linuxes I think it's $HOME/.cache/Code/User/globalStorage/quantum.quantum-devkit-vscode/. Inside this directory delete server/NuGet*.dll to clear our the NuGet references.

@baronfel
Copy link
Member

I raised a matching issue over on the Q# repo, so I'm going to close this one. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-NetSDK untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

2 participants