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

Intellisense not working on macos #5092

Closed
kevo885 opened this issue Mar 6, 2022 · 11 comments
Closed

Intellisense not working on macos #5092

kevo885 opened this issue Mar 6, 2022 · 11 comments

Comments

@kevo885
Copy link

kevo885 commented Mar 6, 2022

Issue Description

Intellisense doesn't seem to be working correctly, it seems to be missing some classes for C#.for example, I notice when I type the beginning words for the class "Input" it won't autocomplete. I am on Mac os with mono, and net core installed. at first my sln and csproj weren't being generated by Unity, so I had to go to Assets -> open C# file directly, while that generated the sln and csproj files, Intellisense still does not work

Steps to Reproduce

create new project in unity, create new script open script in vs code, try to get autocomplete by typing in "Inpu", however Input class does not appear

Expected Behavior

Type something like "GetComp" or "Inp" and GetComponent<> or Input should autocomplete in

Actual Behavior

Typing in the two classes above does not yield either GetComponent nor Input

Things I've tried

  1. installing mono and setting omnisharp.useGlobalMono to always. For mono I downloaded from here: https://www.mono-project.com/download/stable/ - I downloaded the stable channel version is that the right version for m1 mac?
  2. uninstalling / reinstalling net core sdk 6.0
  3. uninstalling / reinstalling mono
  4. manually setting the path to where dotnet is insalled (file is a sym link, the sym link points to /usr/local/share/dotnet/dotnet) : "omnisharp.dotnetPath": "/usr/local/bin/dotnet"

Logs

dotnet and mono info

  • dotnet (6.0.200): /usr/local/bin/dotnet
  • mono (6.12.0.122): /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono

Path

$PATH:$ORACLE_HOME/bin:/usr/vac/bin:/usr/vacpp/bin:/usr/local/share/dotnet/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/bin/mono
export JAVA_HOME=/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

OmniSharp log

Starting OmniSharp server at 3/6/2022, 1:30:36 AM
Target: /Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development/Projects/Rocket boost/Rocket boost.sln

OmniSharp server started with .NET 6.0.200
(/usr/local/bin/dotnet).
Path: /Users/MacBook/.vscode/extensions/ms-dotnettools.csharp-1.24.1/.omnisharp/1.38.1-beta.72-net6.0/OmniSharp.dll
PID: 25414

Starting OmniSharp on Unknown 0.0 (Unknown)
info: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
info: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
info: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.200 17.1.0 - "/usr/local/share/dotnet/sdk/6.0.200/"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.200 17.1.0 - "/usr/local/share/dotnet/sdk/6.0.200/"
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
info: OmniSharp.MSBuild.ProjectSystem
Detecting projects in '/Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development/Projects/Rocket boost/Rocket boost.sln'.
info: OmniSharp.MSBuild.ProjectManager
Queue project update for '/Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development/Projects/Rocket boost/Assembly-CSharp.csproj'
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development/Projects/Rocket boost'.
info: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
info: OmniSharp.WorkspaceInitializer
Configuration finished.
info: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development/Projects/Rocket boost' on host 25170.
info: OmniSharp.MSBuild.ProjectManager
Loading project: /Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development/Projects/Rocket boost/Assembly-CSharp.csproj
fail: OmniSharp.MSBuild.ProjectLoader
This project targets .NET version that requires reference assemblies that do not ship with OmniSharp out of the box (e.g. .NET Framework). The most common solution is to make sure Mono is installed on your machine (https://mono-project.com/download/) and that OmniSharp is started with that Mono installation (e.g. "omnisharp.useGlobalMono":"always" in C# Extension for VS Code).
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development/Projects/Rocket boost/Assembly-CSharp.csproj'.
/Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development/Projects/Rocket boost/Assembly-CSharp.csproj
/usr/local/share/dotnet/sdk/6.0.200/Microsoft.Common.CurrentVersion.targets(1220,5): Error: This project targets .NET version that requires reference assemblies that do not ship with OmniSharp out of the box (e.g. .NET Framework). The most common solution is to make sure Mono is installed on your machine (https://mono-project.com/download/) and that OmniSharp is started with that Mono installation (e.g. "omnisharp.useGlobalMono":"always" in C# Extension for VS Code).

Attempted to update project that is not loaded: /Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development/Projects/Rocket boost/Assembly-CSharp.csproj

device

Macos m1 chip

@filipw
Copy link
Contributor

filipw commented Mar 6, 2022

The reasons are explained in the log

This project targets .NET version that requires reference assemblies that do not ship with OmniSharp out of the box (e.g. .NET Framework). The most common solution is to make sure Mono is installed on your machine (https://mono-project.com/download/) and that OmniSharp is started with that Mono installation (e.g. "omnisharp.useGlobalMono":"always" in C# Extension for VS Code).

@filipw
Copy link
Contributor

filipw commented Mar 6, 2022

Using OmniSharp on global Mono has lower precedence that using .NET 6.0 build of OmniSharp. According to your logs, .NET 6.0 build of OmniSharp is being used.

Make sure to also set "omnisharp.userModernNet": false

@kevo885
Copy link
Author

kevo885 commented Mar 6, 2022

Using OmniSharp on global Mono has lower precedence that using .NET 6.0 build of OmniSharp. According to your logs, .NET 6.0 build of OmniSharp is being used.

Make sure to also set "omnisharp.userModernNet": false

I updated my logs to make it shorter and more relevant as well as included everything I've tried so far. I also set userModerNet to false but after I did that the omnisharp fire logo disappear from my tool bar and now intellisense seems to be completely off.

here is my user settings off everything omnisharp related (I removed "omnisharp.dotnetPath")
"omnisharp.useModernNet": false,
"omnisharp.path": "latest",
"omnisharp.useGlobalMono": "always",

@filipw
Copy link
Contributor

filipw commented Mar 6, 2022

According to the logs, the OmniSharp version in use is .omnisharp/1.38.1-beta.72-net6.0 which is the OmniSharp .NET 6.0 build not the Mono one, and that should only come into play when you set "omnisharp.useModernNet": true,. When started with Mono, you would see something like OmniSharp server started with Mono 6.12.0. in the logs and there would be no -net6.0 suffix in the path.

Please double check this setting because I made the typo above (the setting is "omnisharp.useModernNet" not "omnisharp.userModernNet"). "omnisharp.path": "latest" is also not needed because it opts you into the latest OmniSharp prerelease builds which are pulled from the master branch of OmniSharp and can be instable or even broken.

To summarize, you should have the following for unity development on *nix:

"omnisharp.useModernNet": false,
"omnisharp.useGlobalMono": "always"

If it does not help, try keeping the setting "omnisharp.useModernNet": false and re-install the extension, as that should mean OmniSharp would re-acquire its assets.

@kevo885
Copy link
Author

kevo885 commented Mar 6, 2022

According to the logs, the OmniSharp version in use is .omnisharp/1.38.1-beta.72-net6.0 which is the OmniSharp .NET 6.0 build not the Mono one, and that should only come into play when you set "omnisharp.useModernNet": true,. When started with Mono, you would see something like OmniSharp server started with Mono 6.12.0. in the logs and there would be no -net6.0 suffix in the path.

Please double check this setting because I made the typo above (the setting is "omnisharp.useModernNet" not "omnisharp.userModernNet"). "omnisharp.path": "latest" is also not needed because it opts you into the latest OmniSharp prerelease builds which are pulled from the master branch of OmniSharp and can be instable or even broken.

To summarize, you should have the following for unity development on *nix:

"omnisharp.useModernNet": false,
"omnisharp.useGlobalMono": "always"

If it does not help, try keeping the setting "omnisharp.useModernNet": false and re-install the extension, as that should mean OmniSharp would re-acquire its assets.

So upon setting useModernNet to false with useGlobalMono to "always" and even uninstalling and reinstalling c# extension I get an error saying : [ERROR] Error: Unable to find Mono. Ensure that Mono's '/bin' folder is added to your environment's PATH variable.

I've added Mono /bin folder to my PATH here: export ## PATH=$PATH:/Library/Frameworks/Mono.framework/Versions/Current/bin

I found setting useModernNet = false and keeping useGlobalMono = always and deleting the sln and csproj files makes the error log go away, but Intellisense still missing some autocomplete classes. In this case I suspect the sln and csproj files might be the issue but they were auto generated by unity. Should I keep the sln and csproj files? there were more than one csproj but only one sln from what unity generated

setting useModerNet to false and setting useGlobalMono to 'always' omnisharp log

[ERROR] Error: Unable to find Mono. Ensure that Mono's '/bin' folder is added to your environment's PATH variable.

setting useModernNet to false and setting useGlobalMono to "never" omnisharp log

Starting OmniSharp server at 3/6/2022, 11:51:07 AM
Target: /Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development

OmniSharp server started.
Path: /Users/MacBook/.vscode/extensions/ms-dotnettools.csharp-1.24.1/.omnisharp/1.38.1/run
PID: 38832

Starting OmniSharp on MacOS 12.2.1 (x64)
info: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
info: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
info: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 17.1.0 - "/Users/MacBook/.vscode/extensions/ms-dotnettools.csharp-1.24.1/.omnisharp/1.38.1/omnisharp/.msbuild/Current/Bin"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to '/Users/MacBook/.vscode/extensions/ms-dotnettools.csharp-1.24.1/.omnisharp/1.38.1/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 17.1.0 - "/Users/MacBook/.vscode/extensions/ms-dotnettools.csharp-1.24.1/.omnisharp/1.38.1/omnisharp/.msbuild/Current/Bin"
CscToolExe = csc.exe
MSBuildToolsPath = /Users/MacBook/.vscode/extensions/ms-dotnettools.csharp-1.24.1/.omnisharp/1.38.1/omnisharp/.msbuild/Current/Bin
CscToolPath = /Users/MacBook/.vscode/extensions/ms-dotnettools.csharp-1.24.1/.omnisharp/1.38.1/omnisharp/.msbuild/Current/Bin/Roslyn
BypassFrameworkInstallChecks = true
MSBuildExtensionsPath = /Users/MacBook/.vscode/extensions/ms-dotnettools.csharp-1.24.1/.omnisharp/1.38.1/omnisharp/.msbuild
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
info: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development'.
info: OmniSharp.Cake.CakeProjectSystem
Did not find any Cake files
info: OmniSharp.MSBuild.ProjectSystem
No solution files found in '/Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development'
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development'.
info: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
info: OmniSharp.WorkspaceInitializer
Configuration finished.
info: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development' on host 37863.
info: OmniSharp.OmniSharpWorkspace
Miscellaneous file: /Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development/Rocket boost/Assets/scripts/movement.cs added to workspace
Received response for /v2/codestructure but could not find request.
Received response for /v2/codestructure but could not find request.
Received response for /v2/getcodeactions but could not find request.
Received response for /v2/getcodeactions but could not find request.
Received response for /v2/getcodeactions but could not find request.

setting useModernNet to true and setting useGlobalMono to "always" omnisharp log

Starting OmniSharp server at 3/6/2022, 11:53:20 AM
Target: /Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development

OmniSharp server started with .NET 6.0.200
.
Path: /Users/MacBook/.vscode/extensions/ms-dotnettools.csharp-1.24.1/.omnisharp/1.38.1-net6.0/OmniSharp.dll
PID: 38991

Starting OmniSharp on Unknown 0.0 (Unknown)
info: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
info: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
info: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.200 17.1.0 - "/usr/local/share/dotnet/sdk/6.0.200/"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.200 17.1.0 - "/usr/local/share/dotnet/sdk/6.0.200/"
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
info: OmniSharp.MSBuild.ProjectSystem
No solution files found in '/Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development'
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development'.
info: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
info: OmniSharp.WorkspaceInitializer
Configuration finished.
info: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development' on host 37863.
info: OmniSharp.OmniSharpWorkspace
Miscellaneous file: /Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development/Rocket boost/Assets/scripts/movement.cs added to workspace
Received response for /v2/blockstructure but could not find request.
[warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService
No symbol found. File: /Users/MacBook/Library/Mobile Documents/comappleCloudDocs/game development/Rocket boost/Assets/scripts/movement.cs, Line: 14, Column: 9.
Received response for /completion/resolve but could not find request.

@filipw
Copy link
Contributor

filipw commented Mar 6, 2022

OmniSharp comes in three versions:

  • when you set "omnisharp.useModernNet": true (regardless of other settings), it will run as .NET 6.0 build which supports only .NET Core, .NET 5+ and SDK-style projects which means it will not support Unity development
  • when you set "omnisharp.useModernNet": false and "omnisharp.useGlobalMono": "never", it will run on its own bundled minimal Mono which does not contain .NET Framework reference assemblies. This also means it will not support Unity development
  • when you set "omnisharp.useModernNet": false and "omnisharp.useGlobalMono": "always", it will run on global Mono from your PATH which contains .NET Framework reference assemblies and is the only configuration supporting Unity development.

The extension does not do anything fancy with respect to accessing your PATH - everything is inherited from VS Code, so if something is not visible, the problem likely lies in VS Code itself. However, irrespective of this we have a setting of "omnisharp.monoPath" which, in such situations, can be set to your global Mono installation path, such as /Library/Frameworks/Mono.framework/Versions/Current which should fix it.

@kevo885
Copy link
Author

kevo885 commented Mar 6, 2022

/Library/Frameworks/Mono.framework/Versions/Current

ok I have set useModernNet to false and useGlobalMono to always but I am getting [warn]: OmniSharp.CompositionHostBuilder It looks like you have Mono installed which contains a MSBuild lower than 16.10.0 which is the minimum supported by the configured .NET Core Sdk. I downloaded mono 6.12 and even specify vs code to use 16.12 here: "omnisharp.monoPath": "/Library/Frameworks/Mono.framework/Versions/6.12.0", the warning still appears

@filipw
Copy link
Contributor

filipw commented Mar 6, 2022

I downloaded mono 6.12 and even specify vs code to use 16.12 here

The warning refers to the version of MSBuild. You should install Mono from the preview channel. MSBuild 16.10 was only introduced in Mono 6.12.0.154 while stable channel is Mono 6.12.0.122.

@kevo885
Copy link
Author

kevo885 commented Mar 7, 2022

I downloaded mono 6.12 and even specify vs code to use 16.12 here

The warning refers to the version of MSBuild. You should install Mono from the preview channel. MSBuild 16.10 was only introduced in Mono 6.12.0.154 while stable channel is Mono 6.12.0.122.

I downloaded mono 6.12.0 stable version for macos it still gives warning , was that the right version to download? there were only one other version which was 6.12.0 visual studio channel

@filipw
Copy link
Contributor

filipw commented Mar 7, 2022

you need to download from the preview channel https://www.mono-project.com/download/preview/ where it is 6.12.0.173

@kevo885
Copy link
Author

kevo885 commented Mar 7, 2022

you need to download from the preview channel https://www.mono-project.com/download/preview/ where it is 6.12.0.173

oh thats what you mean by preview channel, looks like that fixed it - omnisharp appears to work properly now. Thank you!

@kevo885 kevo885 closed this as completed Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants