OmniSharp / omnisharp-roslyn

OmniSharp server (HTTP, STDIO) based on Roslyn workspaces
MIT License
1.73k stars 419 forks source link

Omnisharp does not find nuget packages on Fedora Linux 37 #2514

Closed Akselmo closed 1 year ago

Akselmo commented 1 year ago

Hi, I'm trying to get Omnisharp to work with Kate editor.

Basics work like . NET6, but it doesn't find libraries I've included with Nuget. For example I have Raylib-cs in /home/akseli/.nuget/packages/raylib-cs/4.2.0.1/

Am I missing some configuration setting that exposes where nuget folder is to omnisharp?

You can try the project that uses raylib-cs here for troubleshooting: https://codeberg.org/akselmo/Kalma

I'm using Fedora KDE 37

filipw commented 1 year ago

You need to post the full OmniSharp log. In general OmniSharp does not do anything special to handle Nuget packages - it's done by MSBuild.

Akselmo commented 1 year ago

Log from Kate when omnisharp activates

[16:09:11  LSP Server Log] c-sharp@/home/akseli
[Info] OmniSharp.Cake.CakeProjectSystem: Detecting Cake files in '/home/akseli'. |
[16:09:13  LSP Server Log] c-sharp@/home/akseli
[Error] OmniSharp.WorkspaceInitializer: The project system 'OmniSharp.Cake.CakeProjectSystem' threw exception during initialization. - System.UnauthorizedAccessException: Access to the path '/home/akseli/.local/share/Steam/steamapps/compatdata/0/pfx/dosdevices/z:/boot/lost+found' is denied.
 ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
   at System.IO.Enumeration.FileSystemEnumerator`1.Init()
   at System.IO.Enumeration.FileSystemEnumerableFactory.FileSystemInfos(String directory, String expression, EnumerationOptions options, Boolean isNormalized)
   at System.IO.DirectoryInfo.InternalEnumerateInfos(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
   at Microsoft.Extensions.FileSystemGlobbing.Abstractions.DirectoryInfoWrapper.EnumerateFileSystemInfos()+MoveNext()
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Execute()
   at Microsoft.Extensions.FileSystemGlobbing.Matcher.Execute(DirectoryInfoBase directoryInfo)
   at Microsoft.Extensions.FileSystemGlobbing.MatcherExtensions.GetResultsInFullPath(Matcher matcher, String directoryPath)
   at OmniSharp.FileSystem.FileSystemHelper.GetFiles(String includePattern, String targetDirectory) in /home/vsts/work/1/s/src/OmniSharp.Shared/FileSystem/FileSystemHelper.cs:line 42
   at OmniSharp.FileSystem.FileSystemHelper.GetFiles(String includePattern) in /home/vsts/work/1/s/src/OmniSharp.Shared/FileSystem/FileSystemHelper.cs:line 25
   at OmniSharp.Cake.CakeProjectSystem.Initalize(IConfiguration configuration) in /home/vsts/work/1/s/src/OmniSharp.Cake/CakeProjectSystem.cs:line 84
   at OmniSharp.WorkspaceInitializer.Initialize(IServiceProvider serviceProvider, CompositionHost compositionHost) in /home/vsts/work/1/s/src/OmniSharp.Host/WorkspaceInitializer.cs:line 54 |
[16:09:13  LSP Server Log] c-sharp@/home/akseli
[Info] OmniSharp.MSBuild.ProjectSystem: No solution files found in '/home/akseli' |
[16:09:14  LSP Server Log] c-sharp@/home/akseli
[Error] OmniSharp.WorkspaceInitializer: The project system 'OmniSharp.MSBuild.ProjectSystem' threw exception during initialization. - System.UnauthorizedAccessException: Access to the path '/home/akseli/.local/share/Steam/steamapps/compatdata/0/pfx/dosdevices/z:/boot/lost+found' is denied.
 ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
   at System.IO.Enumeration.FileSystemEnumerator`1.Init()
   at System.IO.Enumeration.FileSystemEnumerableFactory.FileSystemInfos(String directory, String expression, EnumerationOptions options, Boolean isNormalized)
   at System.IO.DirectoryInfo.InternalEnumerateInfos(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
   at Microsoft.Extensions.FileSystemGlobbing.Abstractions.DirectoryInfoWrapper.EnumerateFileSystemInfos()+MoveNext()
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Execute()
   at Microsoft.Extensions.FileSystemGlobbing.Matcher.Execute(DirectoryInfoBase directoryInfo)
   at Microsoft.Extensions.FileSystemGlobbing.MatcherExtensions.GetResultsInFullPath(Matcher matcher, String directoryPath)
   at OmniSharp.FileSystem.FileSystemHelper.GetFiles(String includePattern, String targetDirectory) in /home/vsts/work/1/s/src/OmniSharp.Shared/FileSystem/FileSystemHelper.cs:line 42
   at OmniSharp.FileSystem.FileSystemHelper.GetFiles(String includePattern) in /home/vsts/work/1/s/src/OmniSharp.Shared/FileSystem/FileSystemHelper.cs:line 25
   at OmniSharp.MSBuild.ProjectSystem.GetInitialProjectPathsAndIds() in /home/vsts/work/1/s/src/OmniSharp.MSBuild/ProjectSystem.cs:line 153
   at OmniSharp.MSBuild.ProjectSystem.Initalize(IConfiguration configuration) in /home/vsts/work/1/s/src/OmniSharp.MSBuild/ProjectSystem.cs:line 117
   at OmniSharp.WorkspaceInitializer.Initialize(IServiceProvider serviceProvider, CompositionHost compositionHost) in /home/vsts/work/1/s/src/OmniSharp.Host/WorkspaceInitializer.cs:line 54 |
[16:09:14  LSP Server Log] c-sharp@/home/akseli
[Info] OmniSharp.Script.ScriptProjectSystem: Detecting CSX files in '/home/akseli'. |
[16:09:15  LSP Server Log] c-sharp@/home/akseli
[Error] OmniSharp.WorkspaceInitializer: The project system 'OmniSharp.Script.ScriptProjectSystem' threw exception during initialization. - System.UnauthorizedAccessException: Access to the path '/home/akseli/.local/share/Steam/steamapps/compatdata/0/pfx/dosdevices/z:/boot/lost+found' is denied.
 ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
   at System.IO.Enumeration.FileSystemEnumerator`1.Init()
   at System.IO.Enumeration.FileSystemEnumerableFactory.FileSystemInfos(String directory, String expression, EnumerationOptions options, Boolean isNormalized)
   at System.IO.DirectoryInfo.InternalEnumerateInfos(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
   at Microsoft.Extensions.FileSystemGlobbing.Abstractions.DirectoryInfoWrapper.EnumerateFileSystemInfos()+MoveNext()
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
   at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Execute()
   at Microsoft.Extensions.FileSystemGlobbing.Matcher.Execute(DirectoryInfoBase directoryInfo)
   at Microsoft.Extensions.FileSystemGlobbing.MatcherExtensions.GetResultsInFullPath(Matcher matcher, String directoryPath)
   at OmniSharp.FileSystem.FileSystemHelper.GetFiles(String includePattern, String targetDirectory) in /home/vsts/work/1/s/src/OmniSharp.Shared/FileSystem/FileSystemHelper.cs:line 42
   at OmniSharp.FileSystem.FileSystemHelper.GetFiles(String includePattern) in /home/vsts/work/1/s/src/OmniSharp.Shared/FileSystem/FileSystemHelper.cs:line 25
   at OmniSharp.Script.ScriptProjectSystem.Initalize(IConfiguration configuration) in /home/vsts/work/1/s/src/OmniSharp.Script/ScriptProjectSystem.cs:line 64
   at OmniSharp.WorkspaceInitializer.Initialize(IServiceProvider serviceProvider, CompositionHost compositionHost) in /home/vsts/work/1/s/src/OmniSharp.Host/WorkspaceInitializer.cs:line 54 |
[16:09:15  LSP Server Log] c-sharp@/home/akseli
[Info] OmniSharp.WorkspaceInitializer: Configuration finished. |
[16:09:15  LSP Server Log] c-sharp@/home/akseli
[Info] OmniSharp.LanguageServerProtocol.LanguageServerHost: Omnisharp server running using Lsp at location '/home/akseli' on host 15896. |
[16:09:19  LSP Server Log] c-sharp@/home/akseli
[Info] OmniSharp.OmniSharpWorkspace: Miscellaneous file: /home/akseli/Repositories/Kalma/Kalma/Game.cs added to workspace |

Also here is the config that Kate comes for C# LSP by default:

        "c-sharp": {
            "command": ["omnisharp", "-lsp"],
            "commandDebug": ["omnisharp", "--debug", "--verbose"],
            "url": "https://github.com/OmniSharp/omnisharp-roslyn",
            "highlightingModeRegex": "^C#$"
        },

If there is something that looks off in the config, I can try building a new version of Kate with changed configs.

Akselmo commented 1 year ago

For same project, Omnisharp finds the Nuget packages with the C# extension in VSCode.

I used the Omnisharp bundled with the VSCode extension, made a wrapper script to /usr/local/bin/omnisharp and Kate can now use that to run it, however it still is lacking the Nuget packages. What am I missing? What does the VSCode extension do to add those? What is the correct way to install Omnisharp system wide?

filipw commented 1 year ago

So the logs show multiple problems:

Additionally there are multiple builds of OmniSharp so you need to make sure you use the one that is relevant to you. For example VS Code extension can switch between .NET 6.0 build (default) and Mono-based one (when "omnisharp.useModernNet": false was set)

Akselmo commented 1 year ago

Ah thank you a lot for the help! Seems the config was incorrect in Kate's settings.

This config made things work

        "c-sharp": {
            "command": ["omnisharp", "-lsp", "-s", "%{Project:NativePath}"],
            "commandDebug": ["omnisharp", "--debug", "--verbose"],
            "rootIndicationFileNames": ["*.sln", "*.csproj"],
            "url": "https://github.com/OmniSharp/omnisharp-roslyn",
            "highlightingModeRegex": "^C#$"
        }

Will close this, since it was an user error :) Thanks again!