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

Omnisharp not showing up despite reinstall of everything #2391

Closed
nicmar opened this issue Jun 24, 2018 · 29 comments
Closed

Omnisharp not showing up despite reinstall of everything #2391

nicmar opened this issue Jun 24, 2018 · 29 comments

Comments

@nicmar
Copy link

nicmar commented Jun 24, 2018

Everything has been working great for several weeks, all of a sudden it doesn't report errors anymore and Intellisense seems to only suggest hits from inside the current file.

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json):
Version: 2.1.301
Commit: 59524873d6

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.13
OS Platform: Darwin
RID: osx.10.13-x64
Base Path: /usr/local/share/dotnet/sdk/2.1.301/

Host (useful for support):
Version: 2.1.1
Commit: 6985b9f684

.NET Core SDKs installed:
2.1.301 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

VS Code version: 1.24.1
C# Extension version: 1.15.2

Steps to reproduce


I reinstalled the C#-extension several times and it seems to succeed:

Installing C# dependencies...
Platform: darwin, x86_64

Downloading package 'OmniSharp for OSX' (25614 KB).................... Done!
Installing package 'OmniSharp for OSX'

Downloading package '.NET Core Debugger (macOS / x64)' (45653 KB).................... Done!
Installing package '.NET Core Debugger (macOS / x64)'

Finished

I also installed dotnet CLI-tools, which I don't think I had before, I think I just added the setting to ignore it. I also installed MonoFramework-MDK-5.10.1.47.

Expected behavior

The flame icon should show up in the status bar, and errors showing up/intellisense working.

Actual behavior

Omnisharp doesn't seem to load.

I'm not sure if it autoupdated or something, cause it just stopped working from one day to another. If it did, can you disable autoupdates to prevent this from happening again?

Thankful for any tips!

@benm-eras
Copy link

benm-eras commented Jun 25, 2018

So I can get it to work with a new project, but not single .cs files. I am not sure if this is the intended behaviour or not but it explains why I felt it was intermittent!

If I run dotnet new console (for example) then open the generated Program.cs file and give it a sec, I will get intellisense and I can run "Format Document" quite happily. But if I close the folder in VS Code and just open the same Program.cs by double clicking in explorer Omnisharp will not kick in and I get no formatter or intellisense!

From the output window it looks like the it is starting the Omnisharp server when I open the project folder, but not when I open individual .cs files.

Is there a way to tell Omnisharp I want it to run for individual files as well as projects?

@rchande
Copy link

rchande commented Jun 25, 2018

@nicmar Do you have an "omnisharp log" option in your output window?

@benm-eras You are correct. There's currently no support for standalone .cs files. We're tracking that work with OmniSharp/omnisharp-roslyn#207.

@nicmar
Copy link
Author

nicmar commented Jun 26, 2018

@rchande no, the output window is totally empty. There is no "flame icon" which I think there should be for omnisharp. I have tried disabled and enabling the extension "C# for Visual Studio Code (powered by OmniSharp).", but nothing happens.

I uninstalled it, restarted vscode, installed it again, and the second time I got this in the output:

Installing C# dependencies...
Platform: darwin, x86_64

Downloading package 'OmniSharp for OSX' (25614 KB).................... Done!
Installing package 'OmniSharp for OSX'

Downloading package '.NET Core Debugger (macOS / x64)' (45653 KB).................... Done!
Installing package '.NET Core Debugger (macOS / x64)'

Finished

But still nothing. Where is that "Omnisharp log" option supposed to be? There is one option in the select box to the right called C# which shows the log above. The others are like this:

Log (Main)

[2018-06-26 20:54:51.666] [main] [info] update#setState idle
[2018-06-26 20:55:21.673] [main] [info] update#setState checking for updates
[2018-06-26 20:55:22.487] [main] [info] update#setState idle

Log (Shared)

[2018-06-26 20:54:52.245] [sharedprocess] [info] main {"machineId":"6c9d2bc8f91b89624add29c0abeae7fb42bf539fa1cdb2e3e57cd668fa9bcead"}
[2018-06-26 20:54:52.296] [sharedprocess] [info] Scanned user extensions: 0
[2018-06-26 20:54:52.836] [sharedprocess] [info] Scanned system extensions: 70
[2018-06-26 20:54:52.847] [sharedprocess] [info] Deleted from disk ms-vscode.csharp-1.15.2
[2018-06-26 20:54:53.228] [sharedprocess] [info] Scanned user extensions: 0
[2018-06-26 20:54:53.230] [sharedprocess] [info] Scanned user extensions: 0
[2018-06-26 20:54:53.264] [sharedprocess] [info] Scanned system extensions: 70
[2018-06-26 20:54:53.415] [sharedprocess] [info] Scanned user extensions: 0
[2018-06-26 20:54:56.405] [sharedprocess] [info] Scanned user extensions: 0
[2018-06-26 20:54:56.433] [sharedprocess] [info] Scanned user extensions: 0
[2018-06-26 20:54:59.197] [sharedprocess] [info] Scanned user extensions: 0
[2018-06-26 20:54:59.200] [sharedprocess] [info] Scanned user extensions: 0
[2018-06-26 20:54:59.202] [sharedprocess] [info] Scanned user extensions: 0
[2018-06-26 20:54:59.275] [sharedprocess] [info] Scanned user extensions: 0
[2018-06-26 20:54:59.277] [sharedprocess] [info] Scanned system extensions: 70
[2018-06-26 20:54:59.281] [sharedprocess] [info] Scanned system extensions: 70
[2018-06-26 20:54:59.314] [sharedprocess] [info] Scanned system extensions: 70
[2018-06-26 20:54:59.423] [sharedprocess] [info] Installing extension: csharp
[2018-06-26 20:54:59.424] [sharedprocess] [info] Scanned user extensions: 0
[2018-06-26 20:55:00.027] [sharedprocess] [info] Downloaded extension: csharp
[2018-06-26 20:55:03.231] [sharedprocess] [info] Extracted extension to /Users/niclas/.vscode/extensions/.ms-vscode.csharp-1.15.2: ms-vscode.csharp-1.15.2
[2018-06-26 20:55:03.231] [sharedprocess] [info] Renamed to /Users/niclas/.vscode/extensions/ms-vscode.csharp-1.15.2
[2018-06-26 20:55:03.231] [sharedprocess] [info] Installation completed. ms-vscode.csharp-1.15.2
[2018-06-26 20:55:03.275] [sharedprocess] [info] Extensions installed successfully: ms-vscode.csharp
[2018-06-26 20:55:03.399] [sharedprocess] [info] Scanned user extensions: 1
[2018-06-26 20:55:03.417] [sharedprocess] [info] Scanned system extensions: 70
[2018-06-26 20:55:32.255] [sharedprocess] [info] Starting to clean up unused language packs.
[2018-06-26 20:55:33.057] [sharedprocess] [info] Scanned user extensions: 1
[2018-06-26 20:55:33.067] [sharedprocess] [info] Scanned user extensions: 1
[2018-06-26 20:55:33.072] [sharedprocess] [info] Scanned user extensions: 1
[2018-06-26 20:55:33.095] [sharedprocess] [info] Scanned user extensions: 1
[2018-06-26 20:55:33.099] [sharedprocess] [info] Scanned user extensions: 1
[2018-06-26 20:55:33.176] [sharedprocess] [info] Scanned system extensions: 70
[2018-06-26 20:55:33.181] [sharedprocess] [info] Scanned system extensions: 70
[2018-06-26 20:55:33.189] [sharedprocess] [info] Scanned system extensions: 70
[2018-06-26 20:55:33.248] [sharedprocess] [info] Scanned user extensions: 1
[2018-06-26 20:55:36.365] [sharedprocess] [info] Scanned user extensions: 1
[2018-06-26 20:55:36.383] [sharedprocess] [info] Scanned user extensions: 1
[2018-06-26 21:00:36.428] [sharedprocess] [info] Scanned user extensions: 1

Log (Window)

[2018-06-26 20:54:53.490] [renderer1] [info] no standard startup: panel is active
[2018-06-26 20:55:33.345] [renderer1] [info] no standard startup: not a new window

Log (Extension host)

[2018-06-26 20:54:54.248] [exthost1] [info] extension host started
[2018-06-26 20:54:54.274] [exthost1] [info] ExtensionService#_doActivateExtension vscode.emmet {"startup":true,"activationEvent":""}
[2018-06-26 20:54:54.274] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/emmet/out/extension
[2018-06-26 20:54:54.348] [exthost1] [info] ExtensionService#_doActivateExtension vscode.git {"startup":true,"activationEvent":"
"}
[2018-06-26 20:54:54.348] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/out/main
[2018-06-26 20:54:54.534] [exthost1] [info] ExtensionService#_doActivateExtension vscode.merge-conflict {"startup":true,"activationEvent":""}
[2018-06-26 20:54:54.535] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/merge-conflict/out/extension
[2018-06-26 20:54:54.547] [exthost1] [info] ExtensionService#_doActivateExtension vscode.search-rg {"startup":true,"activationEvent":"
"}
[2018-06-26 20:54:54.547] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/search-rg/out/extension
[2018-06-26 20:54:54.554] [exthost1] [info] eager extensions activated
[2018-06-26 20:55:33.983] [exthost1] [info] extension host started
[2018-06-26 20:55:34.012] [exthost1] [info] ExtensionService#_doActivateExtension vscode.emmet {"startup":true,"activationEvent":""}
[2018-06-26 20:55:34.012] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/emmet/out/extension
[2018-06-26 20:55:34.090] [exthost1] [info] ExtensionService#_doActivateExtension vscode.git {"startup":true,"activationEvent":"
"}
[2018-06-26 20:55:34.090] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/out/main
[2018-06-26 20:55:34.263] [exthost1] [info] ExtensionService#_doActivateExtension vscode.merge-conflict {"startup":true,"activationEvent":""}
[2018-06-26 20:55:34.263] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/merge-conflict/out/extension
[2018-06-26 20:55:34.275] [exthost1] [info] ExtensionService#_doActivateExtension vscode.search-rg {"startup":true,"activationEvent":"
"}
[2018-06-26 20:55:34.275] [exthost1] [info] ExtensionService#loadCommonJSModule /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/search-rg/out/extension
[2018-06-26 20:55:34.312] [exthost1] [info] ExtensionService#_doActivateExtension ms-vscode.csharp {"startup":false,"activationEvent":"onLanguage:csharp"}
[2018-06-26 20:55:34.312] [exthost1] [info] ExtensionService#loadCommonJSModule /Users/niclas/.vscode/extensions/ms-vscode.csharp-1.15.2/out/src/main
[2018-06-26 20:55:34.986] [exthost1] [info] eager extensions activated

Does any of these make any sense? :)

@stamminator
Copy link

Same issue for me. I launched a new VS Code window, created a new file, pasted some C# code into it, set the language to C#, and tried to format it. No "Format" option in the context menu, and selecting "Format Document" from the command palette produces the follow error:

There is no document formatter for 'csharp'-files installed.

Please label this as a bug.

@kleber-swf
Copy link

In my case, it was the lack of the .csproj file

@rchande
Copy link

rchande commented Jul 3, 2018

@nicmar To be clear, you're opening a .cs file that's associated with some .csproj? Also, can you share the contents of your vscode settings? I'm particularly curious about your values for settings whose names start with omnisharp

@nicmar
Copy link
Author

nicmar commented Jul 4, 2018

@rchande Hi, I'm using Unity to open a .cs file, but now I see that I don't have a .csproj file named like my project, I have several different like:
_AsmEditor.csproj (5 in total beginning with _Asm)
Assembly-CSharp.csproj (4 in total similar to this one, but for editor, firstpass, etc)
I also have another one called UniteTanks.csproj, which seems to be a leftover of some other project I looked at.

It used to work without a csproj file I believe, as I don't remember deleting one, but stopped working at some point. Can I recreate it from Unity or from VScode somehow?

I have since the problems started reinstalled vscode and the c# extension, so at the moment I have nothing in my vscode settings.

Maybe I should start over with a new Unity project to see if works from there, and maybe move over to that one if it does.

Hmm, thanks a lot for taking the time to help me out!

@nicmar
Copy link
Author

nicmar commented Jul 4, 2018

Yes, with a new project omnisharp works, and this has no .csproj file, however it has a .sln file. My problematic project also has a .sln file which looks very similar to the other one.

Is there anything in here that I should inspect?

@stamminator
Copy link

Is it a given that a simple formatter should require a .csproj file in order to work? I'm not aware of formatting settings being contained in .csproj files (usually they're in some project-level .json file, if anywhere), but even if they are, the extension should just use standard default formatting settings. A .csproj file should not be necessary.

@akshita31
Copy link
Contributor

@stamminator The formatting support is enabled by OmniSharp and currently Omnisharp doesnot support standalone C# files. As @rchande mentioned , we are tracking that work in OmniSharp/omnisharp-roslyn#207

@akshita31
Copy link
Contributor

@nicmar From the logs you shared , it seems that OmniSharp should have started. Could you try setting "omnisharp.path" : "latest" in the settings and then restarting the Omnisharp server (Ctrl+Shift+P --> Restart OmniSharp), and see if any OmniSharp log comes up ?

@nicmar
Copy link
Author

nicmar commented Jul 5, 2018

Hi, I set that in my user settings, and restarted VSCODE, and also tried "Restart omnisharp", but I can't see any log anywhere. All 4 logs are empty. When I press Ctrl+Shift+P -> Select project, it says "Select 1 of 0 project", so it might be that omnisharp doesn't know what project I'm working with.

I see this in the Git log, don't know if it's related.

git rev-parse --show-toplevel
fatal: Not a git repository (or any of the parent directories): .git

I'm trying to uninstall and reinstall the C# extension, but not really seeing anything, here's from the Log (shared):

[2018-07-05 11:27:41.167] [sharedprocess] [info] Downloaded extension: csharp
[2018-07-05 11:27:44.988] [sharedprocess] [info] Extracted extension to /Users/niclas/.vscode/extensions/.ms-vscode.csharp-1.15.2: ms-vscode.csharp-1.15.2
[2018-07-05 11:27:44.989] [sharedprocess] [info] Renamed to /Users/niclas/.vscode/extensions/ms-vscode.csharp-1.15.2
[2018-07-05 11:27:44.989] [sharedprocess] [info] Installation completed. ms-vscode.csharp-1.15.2
[2018-07-05 11:27:45.025] [sharedprocess] [info] Extensions installed successfully: ms-vscode.csharp
[2018-07-05 11:27:45.167] [sharedprocess] [info] Scanned user extensions: 1
[2018-07-05 11:27:45.193] [sharedprocess] [info] Scanned system extensions: 70
[2018-07-05 11:28:06.337] [sharedprocess] [info] Starting to clean up unused language packs.

Anything else I can try? How I open the project so omnisharp detects it?

Like I said, it worked on another new project from Unity.

@rchande
Copy link

rchande commented Jul 5, 2018

@nicmar If it works on a new Unity project, this is probably an issue with your existing projects. Given that you have several .csproj files, if you use Code to open one of the directories that contains a .csproj, and then open a .cs file that is included in that .csproj, what happens?

@niusealeo
Copy link

niusealeo commented Aug 11, 2018

I also have this issue. I am using the latest version of VScode to edit standalone .cs files, but it tells me "There is no document formatter for 'csharp'-files installed." every time I press ctrl+shift+f.

@rchande
Copy link

rchande commented Aug 13, 2018

@willscire Just to confirm, is your C# extension working in scenarios where you have both .cs and .csproj files? I believe failure to format standalone cs files is the same issue we're tracking at OmniSharp/omnisharp-roslyn#207

@ChaosEngine
Copy link

For me helped when I switched from workspace project to folder project

@akshita31
Copy link
Contributor

The latest version of the C# extension - 1.16.0 is out. We have added the support to edit csharp files without the projects. Please let us know if that resolves the problem.

@stamminator
Copy link

@akshita31 works for me! I created a standalone .cs file with abysmal formatting, right-clicked, selected "Format Document", and everything became pretty.

@Squiggle
Copy link

This wasn't working for me (still getting the error 'no formatter for csharp installed...). I'm using a workspace with more than one csharp project.

The non-obvious solution was F1 > "OmniSharp: Select Project" and to select my current project. Only then did code formatting etc start to work. I didn't realise OmniSharp only supported one project at a time in workspaces.

@akshita31
Copy link
Contributor

@nicmar Does the error reproduce for you for the latest version of the extension (1.16.2) ?

@jkoritzinsky
Copy link
Member

It just repro'd for me on 1.16.2 for a stray C# file in my repository.

@akshita31
Copy link
Contributor

@jkoritzinsky Have you opened the folder in which the file is present ?

@jkoritzinsky
Copy link
Member

I've opened a parent folder (5 folders down from the root). Would the fact that I'm in a multi-folder workspace cause an issue?

For reference I'm working on the dotnet/coreclr repo on a unit test project.

@rchande
Copy link

rchande commented Oct 15, 2018

@jkoritzinsky OmniSharp doesn't fully support multi-root workspaces yet (OmniSharp/omnisharp-roslyn#909), so yes, that could be the problem.

@tomasaschan
Copy link

FWIW, I just saw this error in my workspace, and it turned out it was for a completely external reason:

The OmniSharp log showed [ERROR] Error: spawn cmd ENOENT, so I took a look at my PATH environment variable, and noticed that C:\Windows\System32 was missing. Re-adding it fixed the problem for me.

@jasoncavett
Copy link

There still appears to be an issue with workspaces. I have three projects (all have .csproj) - one of which is the executable with two libraries. When I load the workspace in VSCode, Omnisharp always recognizes n - 1 of the projects. I can consistently make this happen.

There are no errors or anything "wrong" showing up in the Omnisharp logs. It just never scans one of the folders that's being loaded into the workspace.

Perhaps this is a different issue?

@rchande
Copy link

rchande commented Mar 21, 2019

@jasoncavett Please file a separate issue and include

  • output of dotnet --info
  • omnisharp log
  • repro steps (if possible)

Thanks!

@wowyota
Copy link

wowyota commented Aug 7, 2023

In my case, it's also missing omnisharp log in the oputput dropdown, then I switch it to c#, finding out it stuck in downloading something. so I reconfig my wifi and vpn, restart vscode to let this download to finish. After that Omnisharp log shows in the dropdown and everything works.

@JoeRobich
Copy link
Member

There have been lots of improvements since this issue was opened. Please open a new issue with logs if you are still running into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests