OmniSharp / homebrew-omnisharp-roslyn

16 stars 19 forks source link

Unable to install on MacOS #3

Closed LandonSchropp closed 7 years ago

LandonSchropp commented 7 years ago

I'm running into and issue when installing Omnisharp using the instructions in the readme. The command fails with the following output:

==> Installing omnisharp from omnisharp/omnisharp-roslyn
==> Tapping aspnet/dnx
Cloning into '/usr/local/Homebrew/Library/Taps/aspnet/homebrew-dnx'...
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 7 (delta 1), reused 2 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), done.
Tapped 2 formulae (30 files, 10.2KB)
==> Installing dependencies for omnisharp/omnisharp-roslyn/omnisharp: mono, aspnet/dnx/dnvm
==> Installing omnisharp/omnisharp-roslyn/omnisharp dependency: mono
==> Downloading https://homebrew.bintray.com/bottles/mono-4.8.0.520.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mono-4.8.0.520.sierra.bottle.tar.gz
==> Caveats
To use the assemblies from other formulae you need to set:
  export MONO_GAC_PREFIX="/usr/local"
Note that the 'mono' formula now includes F#. If you have
the 'fsharp' formula installed, remove it with 'brew uninstall fsharp'.
==> Summary
🍺  /usr/local/Cellar/mono/4.8.0.520: 1,604 files, 242.6MB
==> Installing omnisharp/omnisharp-roslyn/omnisharp dependency: aspnet/dnx/dnvm
==> Cloning https://github.com/aspnet/Home.git
Cloning into '/Users/landon/Library/Caches/Homebrew/dnvm--git'...
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 9 (delta 0), reused 4 (delta 0), pack-reused 0
Unpacking objects: 100% (9/9), done.
==> Checking out branch dev
Error: No such file or directory - dnvm.sh
MadMacMad commented 7 years ago

same here... XXX-MBP:~ Xman$ brew install omnisharp ==> Installing omnisharp from omnisharp/omnisharp-roslyn ==> Installing dependencies for omnisharp/omnisharp-roslyn/omnisharp: aspnet/dnx/dnvm ==> Installing omnisharp/omnisharp-roslyn/omnisharp dependency: aspnet/dnx/dnvm ==> Cloning https://github.com/aspnet/Home.git Updating /Users/xxx/Library/Caches/Homebrew/dnvm--git ==> Checking out branch dev Error: No such file or directory - dnvm.sh

plz help :-) thx

razzmatazz commented 7 years ago

I don't think omnisharp-roslyn server needs dnvm anymore. In addition DNVM has been deprecated in favor of the new dotnet cli UI – see https://github.com/aspnet/dnvm.

This brew tap needs to be updated.. I will take a look at this as I am using it on a mac too albeit I built it from sources myself.

MadMacMad commented 7 years ago

@razzmatazz plz inform us here when you have fixed it... I can not life without autocomplete... many thx

razzmatazz commented 7 years ago

I was looking at it yesterday, and I don't think I have it working yet..

Check out https://github.com/razzmatazz/homebrew-omnisharp-roslyn:

There are two versions of omnisharp on mac os, me myself I am not sure which one is right for .csproj and which one is for .proj/json style projects.

Still figuring out what makes my home-built omnisharp work for me rather than the one from releases page/this tap..

Please tell me if any of these versions (from my repo) work! @MadMacMad @LandonSchropp

ylluminarious commented 7 years ago

Same issue is occurring for me, although I can get $ brew install omnisharp --without-dnvm to "succeed." However, the server has errors when I try to run it after installing it like that and so my Emacs omnisharp plugin is also not working. Here are said errors, obtained by running /usr/local/bin/omnisharp:

OmniSharp: 
info: OmniSharp.Startup[0]
      Omnisharp server running on port '2000' at location '/Users/my_username' on host -1.
info: OmniSharp.DotNet.DotNetProjectSystem[0]
      Initializing in /Users/my_username
info: OmniSharp.DotNet.DotNetProjectSystem[0]
      Auto package restore: True
fail: OmniSharp.Startup[0]
      The project system 'DotNetProjectSystem' threw exception during initialization.
      Failed to initialize Microsoft.DotNet.ProjectModel.WorkspaceContext at /Users/my_username.
         at OmniSharp.DotNet.DotNetProjectSystem.Initalize(IConfiguration configuration)
         at OmniSharp.Startup.Configure(IApplicationBuilder app, IServiceProvider serviceProvider, IOmnisharpEnvironment env, ILoggerFactory loggerFactory, ISharedTextWriter writer, IOmnisharpAssemblyLoader loader, IOptions`1 optionsAccessor)
info: OmniSharp.Startup[0]
      Configuration finished.
ylluminarious commented 7 years ago

@razzmatazz FYI, I installed omnisharp-mono via your repo by first doing $ brew tap razzmatazz/omnisharp-roslyn and then $ brew install omnisharp-mono, but now that I've installed it, how do I use it? I see a /usr/local/Cellar/omnisharp-mono/1.12.0 folder, but the enclosed bin folder is empty and it looks like all of the stuff in libexec is for running a Windows program. Any advice with this?

razzmatazz commented 7 years ago

@ylluminarious – yeah, this bugs me too, actually, I don't know why omnisharp-mono release has no startup script–IMHO there should be a one-liner shell script in distro with something like mono OmniSharp.exe $@ that actually runs omnisharp server but it is not there for some reason. Btw, OmniSharp.exe has Windows PE header and it looks like a Windows executable but it is a .NET binary actually.

ok my plan is to: a) look how omnisharp-node-client selects versions (https://github.com/OmniSharp/omnisharp-node-client/blob/0fa4cfbff6782420057ef731fbf4311fc376061e/lib/helpers/runtime.ts), and if that does not help b) I will ask guys on slack chat

razzmatazz commented 7 years ago

ok, apparently node client (used for the atom editor) uses mono to run OmniSharp.exe on a mac.

however, I wasn't that lucky:

bob@mbp csharptest1 (master)$ mono /usr/local/opt/omnisharp-mono/libexec/OmniSharp.exe
OmniSharp:
System.DllNotFoundException: System.Native
  at (wrapper managed-to-native) Interop+Sys:GetUnixNamePrivate ()
  at Interop+Sys.GetUnixName () [0x00000] in <2c0705c248b844f597694acdb70b3a23>:0
  at System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform (System.Runtime.InteropServices.OSPlatform osPlatform) [0x00009] in <2c0705c248b844f597694acdb70b3a23>:0
  at Microsoft.Extensions.Logging.Console.ConsoleLogger..ctor (System.String name, System.Func`3[T1,T2,TResult] filter, System.Boolean includeScopes) [0x00051] in <e9a418d09ae748d6a3f11d651b9e1106>:0
  at Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider.CreateLoggerImplementation (System.String name) [0x00019] in <e9a418d09ae748d6a3f11d651b9e1106>:0
  at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00037] in <f712f98eb8e445c8918edaf595bbe465>:0
  at Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider.CreateLogger (System.String name) [0x00000] in <e9a418d09ae748d6a3f11d651b9e1106>:0
  at Microsoft.Extensions.Logging.Logger.AddProvider (Microsoft.Extensions.Logging.ILoggerProvider provider) [0x00000] in <7f94c143dddc47f8b60fd6e1fd86a745>:0
  at Microsoft.Extensions.Logging.LoggerFactory.AddProvider (Microsoft.Extensions.Logging.ILoggerProvider provider) [0x00061] in <7f94c143dddc47f8b60fd6e1fd86a745>:0
  at Microsoft.Extensions.Logging.ConsoleLoggerExtensions.AddConsole (Microsoft.Extensions.Logging.ILoggerFactory factory, System.Func`3[T1,T2,TResult] filter, System.Boolean includeScopes) [0x00008] in <e9a418d09ae748d6a3f11d651b9e1106>:0
  at Microsoft.Extensions.Logging.ConsoleLoggerExtensions.AddConsole (Microsoft.Extensions.Logging.ILoggerFactory factory, System.Func`3[T1,T2,TResult] filter) [0x00000] in <e9a418d09ae748d6a3f11d651b9e1106>:0
  at OmniSharp.Startup.Configure (Microsoft.AspNetCore.Builder.IApplicationBuilder app, System.IServiceProvider serviceProvider, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, OmniSharp.Stdio.Services.ISharedTextWriter writer, OmniSharp.Services.IAssemblyLoader loader, Microsoft.Extensions.Options.IOptionsMonitor`1[TOptions] options) [0x00032] in <2e2cacb9896d40f4beaadfde40bd7a78>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <f712f98eb8e445c8918edaf595bbe465>:0
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize () [0x00008] in <24af31b64ae843689736582353a19b3a>:0
  at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build () [0x0008a] in <24af31b64ae843689736582353a19b3a>:0
  at OmniSharp.Program+<>c__DisplayClass1_0.<Run>b__1 () [0x00196] in <2e2cacb9896d40f4beaadfde40bd7a78>:0
  at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x0035b] in <e56ebbc3ed87488b8e26736bbadaa5d3>:0
  at OmniSharp.Program.Run (System.String[] args) [0x001ae] in <2e2cacb9896d40f4beaadfde40bd7a78>:0
  at OmniSharp.Program.Main (System.String[] args) [0x0001c] in <2e2cacb9896d40f4beaadfde40bd7a78>:0

dotnet run OmniSharp.exe doesn't run that much better, complains about missing libhostpolicy.so

this appears to be a can of worms, lets see if we can figure something out with the help of omnisharp server guys

@ylluminarious @LandonSchropp @MadMacMad btw, what clients are you using? emacs, vim? because vscode and atom I think have this figured out automatically?

related issues:

DustinCampbell commented 7 years ago

Yeah, that's because System.Runtime.InteropServices.RuntimeInformation.dll is in the deps file. The issue with this particular binary is that it is Windows-specific on .NET Framework builds.

What version of mono are you running? The latest version had changed the assembly loader to have special handling around this assembly. https://github.com/mono/mono/blob/mono-4.8.0-branch/mono/metadata/image.c#L1035-L1091

razzmatazz commented 7 years ago

hmm, 4.8, however, the one from mono-project.com, not from brew..

bob@mbp csharptest1 (master)$ mono --version
Mono JIT compiler version 4.8.0 (mono-4.8.0-branch/e4a3cf3 Fri Feb 17 15:57:45 EST 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           normal
    SIGSEGV:       altstack
    Notification:  kqueue
    Architecture:  x86
    Disabled:      none
    Misc:          softdebug
    LLVM:          yes(3.6.0svn-mono-master/8b1520c)
    GC:            sgen
DustinCampbell commented 7 years ago

That's likely new enough.

razzmatazz commented 7 years ago

btw, this is binary from v1.12 omnisharp-mono.tgz release

I see there is v1.13 already, but probably doesn't matter that much which one of those I use

DustinCampbell commented 7 years ago

What happens if you launch OmniSharp.exe with the --stdio flag?

razzmatazz commented 7 years ago

mkay, that works! shame I didn't try it myself

bob@mbp csharptest1 (master)$ mono /usr/local/opt/omnisharp-mono/libexec/OmniSharp.exe --stdio
OmniSharp: --stdio
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.Startup","Message":"Omnisharp server running using Stdio at location '/Users/bob/src/omnisharp-tests/csharptest1' on host -1."},"Seq":1,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.DotNet.DotNetProjectSystem","Message":"Initializing in /Users/bob/src/omnisharp-tests/csharptest1"},"Seq":2,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.DotNet.DotNetProjectSystem","Message":"Auto package restore: True"},"Seq":3,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.DotNet.DotNetProjectSystem","Message":"Update workspace context"},"Seq":4,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.DotNet.DotNetProjectSystem","Message":"Resolving projects references"},"Seq":5,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.MSBuildProjectSystem","Message":"MSBUILD_EXE_PATH environment variable set to /usr/local/opt/omnisharp-mono/libexec/msbuild/MSBuild.dll"},"Seq":6,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.MSBuildProjectSystem","Message":"MSBuildExtensionsPath environment variable set to /usr/local/opt/omnisharp-mono/libexec/msbuild"},"Seq":7,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.MSBuildProjectSystem","Message":"MSBuildSDKsPath environment variable set to /usr/local/opt/omnisharp-mono/libexec/msbuild/Sdks"},"Seq":8,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.MSBuildProjectSystem","Message":"Detecting projects in '/Users/bob/src/omnisharp-tests/csharptest1/csharptest1.sln'."},"Seq":9,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.MSBuildProjectSystem","Message":"Loading project from '/Users/bob/src/omnisharp-tests/csharptest1/csharptest1.csproj'."},"Seq":10,"Type":"event"}
Discovered Mono file path: /Library/Frameworks/Mono.framework/Versions/Current/bin//mono
Resolved symbolic link for Mono file path: /Library/Frameworks/Mono.framework/Versions/4.8.0/bin/mono-sgen32
{"Event":"MsBuildProjectDiagnostics","Body":{"FileName":"/Users/bob/src/omnisharp-tests/csharptest1/csharptest1.csproj","Warnings":[],"Errors":[]},"Seq":11,"Type":"event"}
{"Event":"log","Body":{"LogLevel":"INFORMATION","Name":"OmniSharp.MSBuild.MSBuildProjectSystem","Message":"Add project: /Users/bob/src/omnisharp-tests/csharptest1/csharptest1.csproj"},"Seq":12,"Type":"event"}
razzmatazz commented 7 years ago

@DustinCampbell still my questions are:

DustinCampbell commented 7 years ago

shouldn't there be OmniSharp shell script to launch OmniSharp server on unix, using mono? something like one-liner #!/bin/sh + mono OmniSharp.exe $@?

Yes, probably. :smile:

there are two versions for a mac (apparently) on distribution page, omnisharp-mono.tgz and omnisharp-osx-x64-netcoreapp1.1.tar.gz. which one should be recommended for user user to install? what are criterias for selecting each? so I could write this on readme of this repo.. plus would be nice to know w.r.t. omnisharp-emacs development..

omnisharp-mono.tgz is likely the one to use, and it's better to communicate with it over stdio rather than http (which is the default). omnisharp-osx-x64-netcoreapp1.1.tar.gz is a .NET Core standalone version of OmniSharp that has problems with handling .NET Framework .csproj projects. Eventually, the plan is to just do this: https://github.com/omnisharp/omnisharp-roslyn/issues/666.

ylluminarious commented 7 years ago

@razzmatazz Regarding your question about which client I'm using: I'm only using the Emacs one. Thanks for investigating this and providing the extra info. I need omnisharp for my work (lest I use MonoDevelop, lol), so I'm just going to modify omnisharp-server-executable-path to have something like mono /usr/local/opt/omnisharp-mono/libexec/OmniSharp.exe --stdio and see if that works out so that hopefully I can get my development environment in working order again. Thanks.

sjrmanning commented 7 years ago

Hey guys, I've updated the formula to 1.13.0 and removed the outdated dependency on dnvm. It seems to be working fine here on macOS 10.12.4 with mono 4.8.0 installed via brew. Can you try with this new formula and let me know if it works?

razzmatazz commented 7 years ago

@sjrmanning – can you replace -netcoreapp with -mono version on the formula? I think this is how it should be lately.

sjrmanning commented 7 years ago

@razzmatazz The issue with using the -mono version is it then relies on the user using mono /usr/local/opt/omnisharp/libexec/OmniSharp.exe rather than the omnisharp executable installed with the netcoreapp version. But I agree, if we have mono as a dependency it makes sense to use the mono version. It's been a while since I've been using OmniSharp so I'm happy to create some kind of post-install step that makes an alias for the above, but are there any other changes or side-effects you're aware of that I should know or could affect older upgraded installs?

Edit: It seems like this might have issues on macOS. With the -mono version installed mono OmniSharp.exe returns the same System.DllNotFoundException: System.Native error previously mentioned above.

razzmatazz commented 7 years ago

@sjrmanning ok, I propose this:

a) adding a second formula, omnisharp-mono maybe? Like I did in my experiment at https://github.com/razzmatazz/homebrew-omnisharp-roslyn

b) including a bootstrap file in omnisharp-mono.rb formula (or along with it on the repo, I am new to brew), that is basically a two-liner:

    #/bin/sh
    mono /usr/local/opt/omnisharp-mono/libexec/OmniSharp.exe $@

If you don't have time or are not able to test – I can try to do a PR.

This should keep older users able to use the netcoreapp version and still new users would be able to install omnisharp-mono along too.

MadMacMad commented 7 years ago

hello, well I use Sublime Text 3 together with Unity3D on Mac OS X. thx everybody for jumping in...

sjrmanning commented 7 years ago

@razzmatazz We can definitely add another formula, happy to do that, but does mono /usr/local/opt/omnisharp-mono/libexec/OmniSharp.exe currently work for you? See above -- I'm getting this System.DllNotFoundException: System.Native error with the mono version.

@MadMacMad Can you try install again? The new formula should work for your case, but let me know if you still have any issues.

razzmatazz commented 7 years ago

@sjrmanning it does crash for me too, if you just run it w/out any args – it tries to run in http mode then, I think, by default..

but specifying --stdio works (which is what omnisharp-emacs is using, e.g.)

sjrmanning commented 7 years ago

@razzmatazz I've added an omnisharp-mono formula with a simple shell script (couldn't find a cleaner way than what I've got in the formula to do this, but it seems to work anyway). Let me know if it works for you.

ylluminarious commented 7 years ago

@sjrmanning @razzmatazz Thank for the updates and attention to this issue. I just did a fresh install via $ brew install omnisharp/omnisharp-roslyn/omnisharp-mono and was then able to run $ omnisharp --stdio -s ~/some/dir/my.sln without any failures or warnings. Additionally, I was able to set omnisharp-server-executable-path to "/usr/local/bin/omnisharp" in Emacs and C# auto-completion has been working again. Thanks a lot!

razzmatazz commented 7 years ago

@ylluminarious – I think we can close this issue, works for me too.

ylluminarious commented 7 years ago

@razzmatazz Fine by me.

LandonSchropp commented 7 years ago

Works for me as well! Thanks guys.

LandonSchropp commented 7 years ago

If you guys wouldn't mind, it would be great to see the readme updated with the new instructions for getting things set up with the omnisharp-mono package.

razzmatazz commented 7 years ago

@LandonSchropp – I think this information is client/editor specific..

sjrmanning commented 7 years ago

Going to mark this closed now. I've updated the README to recommend omnisharp-mono as it looks like the .NET Core version will eventually be dropped. Thanks for your help everyone!

ghost commented 6 years ago

Hi I keep getting Error: Calling <<-EOS.undent is disabled! Use <<~EOS instead. /usr/local/Homebrew/Library/Taps/omnisharp/homebrew-omnisharp-roslyn/omnisharp-mono.rb:18:ininstall'

what is going on?

ylluminarious commented 6 years ago

@FireAntJoe Homebrew has removed yet another API used in their formulas. They are doing this quite a lot lately; I suppose they hope it will make people's code cleaner, but it's really serving to break lots of stuff. Anyway, this formula is no longer updated. If you're using the Emacs plugin, you should probably use omnisharp-install-server instead of this formula.

ghost commented 6 years ago

@ylluminarious thank you for the information.

ylluminarious commented 6 years ago

@FireAntJoe It seems that omnisharp-vim has specific instructions for installing the server. They seem to do the same thing as Emacs, except that the extraction and path-setting is done manually. Perhaps you could write a vim function to do it automatically and contribute it to omnisharp-vim? Here is the implementation of omnisharp-install-server if you need some pointers on how to do it.

ghost commented 6 years ago

@ylluminarious no thank you, I stay out of that stuff for a reason lol.

ylluminarious commented 6 years ago

@FireAntJoe Ok, no problem.